512 """Parses a log file.
514 The art log file at InputFilePath is parsed.
515 The per-module statistics are added to the existing in AllStats (an instance
516 of JobStatsClass), creating new ones as needed. Similarly, per-event
517 statistics are added to EventStats (a TimeModuleStatsClass instance).
519 options class can contain the following members:
520 - Permissive (default: false): do not bail out when a format error is found;
521 the entry is typically skipped. This often happens because the output line
522 of the timing information is interrupted by some other output.
523 - MaxEvents (default: all events): collect statistics for at most MaxEvents
524 events (always the first ones)
525 - CheckDuplicates (default: false): enables the single-event tracking, that
526 allows to check for duplicates
528 It returns the number of errors encountered.
530 def CompleteEvent(CurrentEvent, EventStats, AllStats):
531 """Make sure that CurrentEvent is known to all stats."""
532 EventStats.complete(( CurrentEvent, ))
533 for ModuleStats
in AllStats:
534 ModuleStats.complete(EventStats.getEvents())
538 LogFile =
OPEN(InputFilePath,
'r')
546 if line == LastLine:
continue
549 if line.startswith(
"TimeModule> "):
553 except FormatError, e:
555 msg =
"Format error on '%s'@%d" % (InputFilePath, iLine + 1)
556 try: msg +=
" (%s)" % str(e.data[
'type'])
557 except KeyError:
pass
558 try: msg +=
", for event " + str(e.data[
'event'])
559 except KeyError:
pass
560 try: msg +=
", module " + str(e.data[
'module'])
561 except KeyError:
pass
562 print >>sys.stderr, msg
563 if not options.Permissive:
raise
568 ModuleStats = AllStats[TimeData.module]
570 ModuleStats = TimeModuleStatsClass \
571 (TimeData.module, bTrackEntries=options.CheckDuplicates)
572 AllStats[TimeData.module] = ModuleStats
575 ModuleStats.add(TimeData)
576 elif line.startswith(
"TimeEvent> "):
579 except FormatError, e:
581 msg =
"Format error on '%s'@%d" % (InputFilePath, iLine + 1)
582 try: msg +=
" (%s)" % str(e.data[
'type'])
583 except KeyError:
pass
584 try: msg +=
", for event " + str(e.data[
'event'])
585 except KeyError:
pass
586 try: msg +=
", module " + str(e.data[
'module'])
587 except KeyError:
pass
588 print >>sys.stderr, msg
589 if not options.Permissive:
raise
593 EventStats.add(TimeData)
594 if (options.MaxEvents >= 0) \
595 and (EventStats.n() >= options.MaxEvents):
596 if CurrentEvent: CompleteEvent(CurrentEvent, EventStats, AllStats)
602 if (CurrentEvent != TimeData.eventKey):
603 if TimeData
and CurrentEvent:
604 CompleteEvent(CurrentEvent, EventStats, AllStats)
605 CurrentEvent = TimeData.eventKey
608 if CurrentEvent: CompleteEvent(CurrentEvent, EventStats, AllStats)