@@ -24,27 +24,14 @@ struct BenchmarkStats {
2424 warmup_iters : u64 ,
2525}
2626
27- #[ derive( Debug , Serialize , Deserialize ) ]
28- /// Configuration for the benchmark
29- /// TODO: actually parse configuration options
27+ #[ derive( Debug , Serialize , Deserialize , Default ) ]
3028struct BenchmarkConfig {
31- warmup_time_ns : f64 ,
32- min_round_time_ns : f64 ,
29+ warmup_time_ns : Option < f64 > ,
30+ min_round_time_ns : Option < f64 > ,
3331 max_time_ns : Option < f64 > ,
3432 max_rounds : Option < u64 > ,
3533}
3634
37- impl Default for BenchmarkConfig {
38- fn default ( ) -> Self {
39- BenchmarkConfig {
40- warmup_time_ns : 0. ,
41- min_round_time_ns : 0. , // TODO: use clock_info
42- max_time_ns : None ,
43- max_rounds : None ,
44- }
45- }
46- }
47-
4835#[ derive( Debug , Serialize , Deserialize ) ]
4936pub struct WalltimeBenchmark {
5037 #[ serde( flatten) ]
@@ -56,11 +43,7 @@ pub struct WalltimeBenchmark {
5643
5744impl From < RawWallTimeData > for WalltimeBenchmark {
5845 fn from ( value : RawWallTimeData ) -> Self {
59- let times_ns: Vec < f64 > = value
60- . times_ps
61- . into_iter ( )
62- . map ( |t| ( t as f64 ) / 1_000. )
63- . collect ( ) ;
46+ let times_ns: Vec < f64 > = value. times_ns . iter ( ) . map ( |& t| t as f64 ) . collect ( ) ;
6447 let mut data = Data :: new ( times_ns. clone ( ) ) ;
6548 let rounds = data. len ( ) as u64 ;
6649 let total_time = times_ns. iter ( ) . sum :: < f64 > ( ) / 1_000_000_000.0 ;
@@ -115,7 +98,10 @@ impl From<RawWallTimeData> for WalltimeBenchmark {
11598 name : value. metadata . name ,
11699 uri : value. metadata . uri ,
117100 } ,
118- config : BenchmarkConfig :: default ( ) ,
101+ config : BenchmarkConfig {
102+ max_time_ns : value. max_time_ns . map ( |t| t as f64 ) ,
103+ ..Default :: default ( )
104+ } ,
119105 stats,
120106 }
121107 }
@@ -127,8 +113,16 @@ struct Instrument {
127113 type_ : String ,
128114}
129115
116+ #[ derive( Debug , Serialize , Deserialize ) ]
117+ struct Creator {
118+ name : String ,
119+ version : String ,
120+ pid : u32 ,
121+ }
122+
130123#[ derive( Debug , Serialize , Deserialize ) ]
131124pub struct WalltimeResults {
125+ creator : Creator ,
132126 instrument : Instrument ,
133127 benchmarks : Vec < WalltimeBenchmark > ,
134128}
@@ -139,6 +133,11 @@ impl WalltimeResults {
139133 instrument : Instrument {
140134 type_ : "walltime" . to_string ( ) ,
141135 } ,
136+ creator : Creator {
137+ name : "codspeed-rust" . to_string ( ) ,
138+ version : env ! ( "CARGO_PKG_VERSION" ) . to_string ( ) ,
139+ pid : std:: process:: id ( ) ,
140+ } ,
142141 benchmarks,
143142 }
144143 }
0 commit comments