1 module testquark.defines;
2 import std.json;
3 public struct NamedBenchmark
4 {
5 	string name;
6 	string module_;
7 	int line;
8 	size_t iterations = 1;
9 	this(string n, size_t iter = 1, int l = __LINE__, string f = __MODULE__)
10 	{
11 		name = n;
12 		line = l;
13 		module_ = f;
14 		iterations = iter;
15 	}
16 
17 	JSONValue toJson()
18 	{
19 		return JSONValue([
20 				"name": JSONValue(name),
21 				"module": JSONValue(module_),
22 				"defined": JSONValue(line)
23 				]);
24 	}
25 }
26 template location(alias x, string xx)
27 {
28     enum l = __traits(getLocation, x);
29     enum location = NamedBenchmark(xx, l[1], l[0]);
30 }
31 
32 package 
33 struct TestResult
34 			{
35 				NamedBenchmark src;
36 				float mean;
37 				float min, max;
38 				float stdandardDeviation;
39 				this(NamedBenchmark s)
40 				{
41 					src = s;
42 				}
43 
44 				JSONValue toJson()
45 				{
46 					return JSONValue([
47 							"src": src.toJson,
48 							"timeUnit": JSONValue("us"),
49 							"mean": JSONValue(mean),
50 							"min": JSONValue(min),
51 							"max": JSONValue(max),
52 							"standardDeviation": JSONValue(stdandardDeviation)
53 							]);
54 				}
55 			}