-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathimport_report.py
More file actions
56 lines (45 loc) · 2.13 KB
/
import_report.py
File metadata and controls
56 lines (45 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import click
@click.command("importreport", short_help="import simple space separated "
"data into a report to submit.")
@click.argument("input", type=click.File('r'), default="-", required=False)
@click.argument("output", type=click.File('w'), default="report.json",
required=False)
@click.option("--testsuite", "suite", default="nts", show_default=True,
required=True, help="short name of the test suite to submit to")
@click.option("--order", required=True, help="Order to submit as number. "
"Ex: a svn revision, or timestamp.")
@click.option("--machine", required=True,
help="the name of the machine to submit under")
def action_importreport(input, output, suite, order, machine):
"""Import simple data into LNT. This takes a space separated
key value file and creates an LNT report file, which can be submitted to
an LNT server. Example input file:
\b
foo.exec 123
bar.size 456
foo/bar/baz.size 789
The format is "test-name.metric", so exec and size are valid metrics for
the test suite you are submitting to.
"""
import lnt.testing
import os
machine = lnt.testing.Machine(machine)
ctime = os.path.getctime(input.name)
mtime = os.path.getmtime(input.name)
run = lnt.testing.Run(start_time=ctime, end_time=mtime,
info={'llvm_project_revision': order})
tests = {} # name => lnt.testing.Test
for line in input.readlines():
key, val = line.split()
(testname, metric) = key.split(".")
metric_type = float if metric not in ("hash", "profile") else str
if testname not in tests:
tests[testname] = lnt.testing.Test(testname, [])
test = tests[testname]
samples = next((s for s in test.samples if s.metric == metric), None)
if samples is None:
test.samples.append(lnt.testing.MetricSamples(metric, []))
samples = test.samples[-1]
samples.add_samples([val], conv_f=metric_type)
report = lnt.testing.Report(machine=machine, run=run, tests=list(tests.values()))
output.write(report.render())