add timing
Browse files- logscoremetric.py +8 -0
logscoremetric.py
CHANGED
@@ -19,6 +19,8 @@ import re
|
|
19 |
import dateutil.parser
|
20 |
import numpy as np
|
21 |
|
|
|
|
|
22 |
|
23 |
# TODO: Add BibTeX citation
|
24 |
_CITATION = """\
|
@@ -136,6 +138,8 @@ class LogScoreMetric(evaluate.Metric):
|
|
136 |
def _compute(self, predictions, references):
|
137 |
"""Returns the scores"""
|
138 |
|
|
|
|
|
139 |
timestamp_score = np.mean([self.getLogMetric(p,r) for p,r in zip(predictions,references)])
|
140 |
predictions_without_timestamps = [re.sub(self.timestamp_regex, '', p, flags=re.MULTILINE) for p in predictions]
|
141 |
references_without_timestamps = [re.sub(self.timestamp_regex, '', r, flags=re.MULTILINE) for r in references]
|
@@ -143,7 +147,11 @@ class LogScoreMetric(evaluate.Metric):
|
|
143 |
# Sacrebleu score on logs without timestamps
|
144 |
sb_results = self.sacrebleu.compute(predictions=predictions_without_timestamps, references=references_without_timestamps)
|
145 |
|
|
|
|
|
|
|
146 |
return {
|
147 |
"timestamp_score": timestamp_score,
|
148 |
"sacrebleu_score": sb_results["score"],
|
|
|
149 |
}
|
|
|
19 |
import dateutil.parser
|
20 |
import numpy as np
|
21 |
|
22 |
+
import time
|
23 |
+
|
24 |
|
25 |
# TODO: Add BibTeX citation
|
26 |
_CITATION = """\
|
|
|
138 |
def _compute(self, predictions, references):
|
139 |
"""Returns the scores"""
|
140 |
|
141 |
+
t_before = time.perf_counter()
|
142 |
+
|
143 |
timestamp_score = np.mean([self.getLogMetric(p,r) for p,r in zip(predictions,references)])
|
144 |
predictions_without_timestamps = [re.sub(self.timestamp_regex, '', p, flags=re.MULTILINE) for p in predictions]
|
145 |
references_without_timestamps = [re.sub(self.timestamp_regex, '', r, flags=re.MULTILINE) for r in references]
|
|
|
147 |
# Sacrebleu score on logs without timestamps
|
148 |
sb_results = self.sacrebleu.compute(predictions=predictions_without_timestamps, references=references_without_timestamps)
|
149 |
|
150 |
+
t_after = time.perf_counter()
|
151 |
+
compute_duration = f" {t_after - t_before:0.4f}"
|
152 |
+
|
153 |
return {
|
154 |
"timestamp_score": timestamp_score,
|
155 |
"sacrebleu_score": sb_results["score"],
|
156 |
+
"compute_duration":compute_duration
|
157 |
}
|