Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /benchmarks/analysis/benchmark.sml
ViewVC logotype

Diff of /benchmarks/analysis/benchmark.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3059, Fri Mar 13 17:24:26 2015 UTC revision 3070, Sat Mar 14 21:36:57 2015 UTC
# Line 36  Line 36 
36    (* load a list of benchmark report files, returning a list of benchmarks *)    (* load a list of benchmark report files, returning a list of benchmarks *)
37      val loadFiles : string list -> benchmark list      val loadFiles : string list -> benchmark list
38    
39      (* store a list of benchmark records as a JSON file *)
40        val storeFile : benchmark list * string -> unit
41    
42      (* conversion to and from JSON representation *)
43      val fromJSON : JSON.value -> benchmark list      val fromJSON : JSON.value -> benchmark list
44      val toJSON : benchmark list -> JSON.value      val toJSON : benchmark list -> JSON.value
45    
# Line 173  Line 177 
177      fun fromJSON (J.ARRAY objs) = List.map jsonToBenchmark objs      fun fromJSON (J.ARRAY objs) = List.map jsonToBenchmark objs
178        | fromJSON obj = [jsonToBenchmark obj]        | fromJSON obj = [jsonToBenchmark obj]
179    
180      fun resultsToJSON (r : results) = raise Fail "TODO"      fun resultsToJSON (r : results) = let
181            (* build reverse-order list of fields *)
182              val fields = []
183              val fields = ("name", J.STRING(#name r)) :: fields
184              val fields = ("nprocs", J.INT(IntInf.fromInt(#nprocs r))) :: fields
185              val fields = ("times", J.ARRAY(List.map J.FLOAT (#times r))) :: fields
186              val fields = (case #avg_time r
187                     of SOME t => ("avg-time", J.FLOAT t) :: fields
188                      | NONE => fields
189                    (* end case *))
190              val fields = (case #std_dev r
191                     of SOME t => ("std-dev", J.FLOAT t) :: fields
192                      | NONE => fields
193                    (* end case *))
194              in
195                J.OBJECT(List.rev fields)
196              end
197    
198      fun benchmarkToJSON (b : benchmark) = raise Fail "TODO"      fun benchmarkToJSON (b : benchmark) = let
199            (* build reverse-order list of fields *)
200              val fields = []
201              val fields = ("bmark", J.STRING(#bmark b)) :: fields
202              val fields = ("host", J.STRING(#host b)) :: fields
203              val fields = ("version", J.STRING(#version b)) :: fields
204              val fields = ("nruns", J.INT(IntInf.fromInt(#nruns b))) :: fields
205              val fields = ("max-nprocs", J.INT(IntInf.fromInt(#max_nprocs b))) :: fields
206              val fields = ("max-nworkers", J.INT(IntInf.fromInt(#max_nworkers b))) :: fields
207              val fields = ("date", J.STRING(#date b)) :: fields
208              val fields = ("time", J.STRING(#time b)) :: fields
209              val fields = ("diderotc-flags", J.STRING(#diderotc_flags b)) :: fields
210              val fields = ("runtime-flags", J.STRING(#runtime_flags b)) :: fields
211              val fields = ("results", J.ARRAY(List.map resultsToJSON (#results b))) :: fields
212              val fields = ("completed-at", J.STRING(#completed_at b)) :: fields
213              in
214                J.OBJECT(List.rev fields)
215              end
216    
217      fun toJSON [b] = benchmarkToJSON b      fun toJSON [b] = benchmarkToJSON b
218        | toJSON bs = JSON.ARRAY(List.map benchmarkToJSON bs)        | toJSON bs = JSON.ARRAY(List.map benchmarkToJSON bs)
# Line 184  Line 221 
221            (fn (f, bmarks) => fromJSON (JSONParser.parseFile f) @ bmarks)            (fn (f, bmarks) => fromJSON (JSONParser.parseFile f) @ bmarks)
222              [] fs              [] fs
223    
224      (* store a list of benchmark records as a JSON file *)
225        fun storeFile (bmarks, file) = let
226              val outS = TextIO.openOut file
227              in
228                JSONPrinter.print' {strm=outS, pretty=true} (toJSON bmarks)
229                  handle ex => (TextIO.closeOut outS; raise ex);
230                TextIO.closeOut outS
231              end
232    
233    end    end

Legend:
Removed from v.3059  
changed lines
  Added in v.3070

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0