added more fine-grained timing
Browse files- logscoremetric.py +15 -4
logscoremetric.py
CHANGED
@@ -143,20 +143,31 @@ class LogScoreMetric(evaluate.Metric):
|
|
143 |
def _compute(self, predictions, references):
|
144 |
"""Returns the scores"""
|
145 |
|
146 |
-
|
147 |
|
148 |
timestamp_score = np.mean([self.getLogMetric(p,r) for p,r in zip(predictions,references)])
|
|
|
|
|
|
|
149 |
predictions_without_timestamps = [self.timestamp_pattern.sub('', p) for p in predictions]
|
150 |
references_without_timestamps = [self.timestamp_pattern.sub('', r) for r in references]
|
151 |
|
|
|
|
|
152 |
# Sacrebleu score on logs without timestamps
|
153 |
sb_results = self.sacrebleu.compute(predictions=predictions_without_timestamps, references=references_without_timestamps)
|
154 |
|
155 |
-
|
156 |
-
|
|
|
|
|
|
|
157 |
|
158 |
return {
|
159 |
"timestamp_score": timestamp_score,
|
160 |
"sacrebleu_score": sb_results["score"],
|
161 |
-
"
|
|
|
|
|
|
|
162 |
}
|
|
|
143 |
def _compute(self, predictions, references):
|
144 |
"""Returns the scores"""
|
145 |
|
146 |
+
t_before_logmetric = time.perf_counter()
|
147 |
|
148 |
timestamp_score = np.mean([self.getLogMetric(p,r) for p,r in zip(predictions,references)])
|
149 |
+
|
150 |
+
t_after_logmetric = t_before_timestamp_rm = time.perf_counter()
|
151 |
+
|
152 |
predictions_without_timestamps = [self.timestamp_pattern.sub('', p) for p in predictions]
|
153 |
references_without_timestamps = [self.timestamp_pattern.sub('', r) for r in references]
|
154 |
|
155 |
+
t_after_timestamp_rm = t_before_sacrebleu = time.perf_counter()
|
156 |
+
|
157 |
# Sacrebleu score on logs without timestamps
|
158 |
sb_results = self.sacrebleu.compute(predictions=predictions_without_timestamps, references=references_without_timestamps)
|
159 |
|
160 |
+
t_after_sacrebleu = time.perf_counter()
|
161 |
+
logmetric_duration = f" {t_after_logmetric - t_before_logmetric:0.10f}"
|
162 |
+
timestamp_rm_duration = f" {t_after_timestamp_rm - t_before_timestamp_rm:0.10f}"
|
163 |
+
sacrebleu_duration = f" {t_after_sacrebleu - t_before_sacrebleu:0.10f}"
|
164 |
+
overall_duration = f" {t_after_sacrebleu - t_before_logmetric:0.10f}"
|
165 |
|
166 |
return {
|
167 |
"timestamp_score": timestamp_score,
|
168 |
"sacrebleu_score": sb_results["score"],
|
169 |
+
"logmetric_duration":logmetric_duration,
|
170 |
+
"timestamp_rm_duration":timestamp_rm_duration,
|
171 |
+
"sacrebleu_duration":sacrebleu_duration,
|
172 |
+
"overall_duration":overall_duration
|
173 |
}
|