This is an archive of the discontinued LLVM Phabricator instance.

[LIT] Add JSONMetricValue type to wrap types supported by the json encoder.
ClosedPublic

Authored by EricWF on Dec 8 2014, 4:47 PM.

Details

Summary

The following types can be encoded and decoded by the json library:
dict, list, tuple, str, unicode, int, long, float, bool, NoneType.

JSONMetricValue can be constructed with any of these types, and used as part of Test.Result.
This patch also adds a toMetricValue function that converts a value into a MetricValue.

Diff Detail

Event Timeline

EricWF updated this revision to Diff 17062.Dec 8 2014, 4:47 PM
EricWF retitled this revision from to [LIT] Add NativeMetricValue type to wrap types supported by the json encoder..
EricWF updated this object.
EricWF edited the test plan for this revision. (Show Details)
EricWF added a reviewer: ddunbar.
EricWF added subscribers: Unknown Object (MLST), Unknown Object (MLST).
ddunbar edited edge metadata.Dec 9 2014, 4:25 PM

The MetricValue abstraction doesn't currently provide any value really, but it is there in case we ever wanted to make use of the values (e.g., report performance changes). Given that, I think it probably makes sense to just call this JSONMetricValue and make it explicit that this is tied to values which are representable in the output, but which will otherwise be uninterpreted.

utils/lit/lit/Test.py
78

Wouldn't isinstance() be more canonical?

Also, this should probably verify that the container data types themselves contain representable items. Does the json lib provide a function to do that?

96

Same note re: isinstance().

EricWF added a comment.Dec 9 2014, 5:14 PM

I'll make the requested changes.

utils/lit/lit/Test.py
78

You could create a JSONEncoder object and encode it on the spot and throw away the result. However there is nothing you can do to prevent the value from changing after the check.

You can't keep the encoded string because you'll end up re-encoding the string later.

EricWF updated this revision to Diff 17113.Dec 9 2014, 9:18 PM
EricWF retitled this revision from [LIT] Add NativeMetricValue type to wrap types supported by the json encoder. to [LIT] Add JSONMetricValue type to wrap types supported by the json encoder..
EricWF updated this object.
EricWF edited edge metadata.

Implement @ddunbar's changes.

EricWF updated this revision to Diff 17520.Dec 19 2014, 2:27 PM

Remove poorly named function. It's unneeded.

EricWF accepted this revision.Dec 19 2014, 2:27 PM
EricWF added a reviewer: EricWF.

Accepting.

This revision is now accepted and ready to land.Dec 19 2014, 2:27 PM
EricWF closed this revision.Dec 19 2014, 2:29 PM