|
8 | 8 | import collections
|
9 | 9 | import logging
|
10 | 10 | import os
|
| 11 | +import re |
11 | 12 | import sys
|
12 | 13 |
|
13 | 14 | import matplotlib.pyplot as plt
|
@@ -141,7 +142,16 @@ def _read(self, fh, fname):
|
141 | 142 |
|
142 | 143 | def parse_line(line):
|
143 | 144 | """Parse single line."""
|
144 |
| - name, vals = line[:25], line[25:].split() |
| 145 | + # Assume the first element of the values is a float. Use the first |
| 146 | + # float appearing as a split between the name and the values. |
| 147 | + # Also only digits, "." and spaces can be present after the fist float. |
| 148 | + match = re.search(r"\s(\d+\.\d+[-\d.\s]*)$", line) |
| 149 | + if not match: |
| 150 | + raise self.Error(f"Cannot properly split line in label and values: {line}") |
| 151 | + split_index = match.start() |
| 152 | + name = line[:split_index].rstrip() |
| 153 | + vals = line[split_index:].strip().split() |
| 154 | + |
145 | 155 | try:
|
146 | 156 | ctime, cfract, wtime, wfract, ncalls, gflops = vals
|
147 | 157 | except ValueError:
|
@@ -712,15 +722,11 @@ def to_table(self, sort_key="wall_time", stop=None):
|
712 | 722 |
|
713 | 723 | def get_dataframe(self, sort_key="wall_time", **kwargs):
|
714 | 724 | """Return a pandas DataFrame with entries sorted according to `sort_key`."""
|
715 |
| - frame = pd.DataFrame(columns=AbinitTimerSection.FIELDS) |
716 |
| - |
717 |
| - for osect in self.order_sections(sort_key): |
718 |
| - frame = frame.append(osect.to_dict(), ignore_index=True) |
| 725 | + data = [osect.to_dict() for osect in self.order_sections(sort_key)] |
| 726 | + frame = pd.DataFrame(data, columns=AbinitTimerSection.FIELDS) |
719 | 727 |
|
720 | 728 | # Monkey patch
|
721 | 729 | frame.info = self.info
|
722 |
| - frame.cpu_time = self.cpu_time |
723 |
| - frame.wall_time = self.wall_time |
724 | 730 | frame.mpi_nprocs = self.mpi_nprocs
|
725 | 731 | frame.omp_nthreads = self.omp_nthreads
|
726 | 732 | frame.mpi_rank = self.mpi_rank
|
|
0 commit comments