Skip to content

Commit

Permalink
update abitimer
Browse files Browse the repository at this point in the history
  • Loading branch information
gpetretto committed Mar 10, 2025
1 parent 4ca6092 commit b2700b8
Show file tree
Hide file tree
Showing 3 changed files with 931 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/pymatgen/io/abinit/abitimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import collections
import logging
import os
import re
import sys

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -141,7 +142,16 @@ def _read(self, fh, fname):

def parse_line(line):
"""Parse single line."""
name, vals = line[:25], line[25:].split()
# Assume the first element of the values is a float. Use the first
# float appearing as a split between the name and the values.
# Also only digits, "." and spaces can be present after the fist float.
match = re.search(r"\s(\d+\.\d+[-\d.\s]*)$", line)
if not match:
raise self.Error(f"Cannot properly split line in label and values: {line}")
split_index = match.start()
name = line[:split_index].rstrip()
vals = line[split_index:].strip().split()

try:
ctime, cfract, wtime, wfract, ncalls, gflops = vals
except ValueError:
Expand Down Expand Up @@ -712,15 +722,11 @@ def to_table(self, sort_key="wall_time", stop=None):

def get_dataframe(self, sort_key="wall_time", **kwargs):
"""Return a pandas DataFrame with entries sorted according to `sort_key`."""
frame = pd.DataFrame(columns=AbinitTimerSection.FIELDS)

for osect in self.order_sections(sort_key):
frame = frame.append(osect.to_dict(), ignore_index=True)
data = [osect.to_dict() for osect in self.order_sections(sort_key)]
frame = pd.DataFrame(data, columns=AbinitTimerSection.FIELDS)

# Monkey patch
frame.info = self.info
frame.cpu_time = self.cpu_time
frame.wall_time = self.wall_time
frame.mpi_nprocs = self.mpi_nprocs
frame.omp_nthreads = self.omp_nthreads
frame.mpi_rank = self.mpi_rank
Expand Down
Loading

0 comments on commit b2700b8

Please sign in to comment.