11open Stdune
22module Timestamp = Chrome_trace.Event. Timestamp
33
4+ let make_ts ts = Timestamp. of_float_seconds (Time. to_secs ts)
5+ let make_dur span = Timestamp. of_float_seconds (Time.Span. to_secs span)
6+
47module Async = struct
58 type data =
69 { args : Chrome_trace.Event .args option
@@ -38,11 +41,11 @@ type t = Chrome_trace.Event.t
3841let scan_source ~name ~start ~stop ~dir =
3942 let module Event = Chrome_trace. Event in
4043 let module Timestamp = Event. Timestamp in
41- let dur = Time. diff stop start |> Time.Span. to_secs |> Timestamp. of_float_seconds in
44+ let dur = make_dur ( Time. diff stop start) in
4245 let common =
4346 Event. common_fields
4447 ~name: (name ^ " : " ^ Path.Source. to_string dir)
45- ~ts: (Timestamp. of_float_seconds ( Time. to_secs start) )
48+ ~ts: (make_ts start)
4649 ()
4750 in
4851 let args = [ " dir" , `String (Path.Source. to_string dir) ] in
@@ -52,7 +55,7 @@ let scan_source ~name ~start ~stop ~dir =
5255let evalauted_rules ~rule_total =
5356 let open Chrome_trace in
5457 let args = [ " value" , `Int rule_total ] in
55- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
58+ let ts = make_ts (Time. now () ) in
5659 let common = Event. common_fields ~name: " evaluated_rules" ~ts () in
5760 Event. counter common args
5861;;
@@ -71,23 +74,21 @@ let config ~version =
7174 | Some v -> (" version" , Stdune.Json. string v) :: args
7275 in
7376 let open Chrome_trace in
74- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
77+ let ts = make_ts (Time. now () ) in
7578 let common = Event. common_fields ~cat: [ " config" ] ~name: " config" ~ts () in
7679 Event. instant ~args common
7780;;
7881
7982let exit () =
8083 let open Chrome_trace in
81- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
84+ let ts = make_ts (Time. now () ) in
8285 let common = Event. common_fields ~cat: [ " config" ] ~name: " exit" ~ts () in
8386 Event. instant common
8487;;
8588
8689let scheduler_idle () =
8790 let fields =
88- let ts =
89- Chrome_trace.Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs)
90- in
91+ let ts = make_ts (Time. now () ) in
9192 Chrome_trace.Event. common_fields ~name: " watch mode iteration" ~ts ()
9293 in
9394 (* the instant event allows us to separate build commands from
@@ -145,7 +146,7 @@ let process
145146 | Some n -> n
146147 | None -> Filename. basename prog
147148 in
148- let ts = Timestamp. of_float_seconds ( Time. to_secs started_at) in
149+ let ts = make_ts started_at in
149150 Event. common_fields ~cat: (Category. to_string Process :: categories) ~name ~ts ()
150151 in
151152 let always =
@@ -182,20 +183,15 @@ let process
182183 ]
183184 in
184185 let args = always @ extended in
185- let dur = Event.Timestamp. of_float_seconds ( Time.Span. to_secs times.elapsed_time) in
186+ let dur = make_dur times.elapsed_time in
186187 Event. complete ~args ~dur common
187188;;
188189
189190let persistent ~file ~module_ what ~start ~stop =
190191 let module Event = Chrome_trace. Event in
191192 let module Timestamp = Event. Timestamp in
192- let dur = Time. diff stop start |> Time.Span. to_secs |> Timestamp. of_float_seconds in
193- let common =
194- Event. common_fields
195- ~name: " db"
196- ~ts: (Timestamp. of_float_seconds (Time. to_secs start))
197- ()
198- in
193+ let dur = make_dur (Time. diff stop start) in
194+ let common = Event. common_fields ~name: " db" ~ts: (make_ts start) () in
199195 let args =
200196 [ " path" , `String (Path. to_string file)
201197 ; " module" , `String module_
@@ -222,7 +218,7 @@ module Rpc = struct
222218 let session ~id stage =
223219 let open Chrome_trace in
224220 let common =
225- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
221+ let ts = make_ts (Time. now () ) in
226222 Event. common_fields ~ts ~name: " rpc_session" ()
227223 in
228224 let id = Chrome_trace.Id. create (`Int id) in
@@ -247,7 +243,7 @@ module Rpc = struct
247243 | `Notification -> args
248244 | `Request id -> (" request_id" , to_json id) :: args
249245 in
250- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
246+ let ts = make_ts (Time. now () ) in
251247 let common = Event. common_fields ~cat: [ Category. to_string Rpc ] ~ts ~name () in
252248 Event. async
253249 (Chrome_trace.Id. create (`Int id))
@@ -258,7 +254,7 @@ module Rpc = struct
258254
259255 let packet_read ~id ~success ~error =
260256 let open Chrome_trace in
261- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
257+ let ts = make_ts (Time. now () ) in
262258 let args =
263259 let base = [ " id" , `Int id; " success" , `Bool success ] in
264260 match error with
@@ -277,7 +273,7 @@ module Rpc = struct
277273
278274 let packet_write ~id ~count =
279275 let open Chrome_trace in
280- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
276+ let ts = make_ts (Time. now () ) in
281277 let args = [ " id" , `Int id; " count" , `Int count ] in
282278 let common =
283279 Event. common_fields
@@ -291,7 +287,7 @@ module Rpc = struct
291287
292288 let accept ~success ~error =
293289 let open Chrome_trace in
294- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
290+ let ts = make_ts (Time. now () ) in
295291 let args =
296292 let base = [ " success" , `Bool success ] in
297293 match error with
@@ -306,7 +302,7 @@ module Rpc = struct
306302
307303 let close ~id =
308304 let open Chrome_trace in
309- let ts = Time. now () |> Time. to_secs |> Event.Timestamp. of_float_seconds in
305+ let ts = make_ts ( Time. now () ) in
310306 let args = [ " id" , `Int id ] in
311307 let common =
312308 Event. common_fields ~cat: [ Category. to_string Rpc ; " session" ] ~name: " close" ~ts ()
318314let gc () =
319315 let module Event = Chrome_trace. Event in
320316 let module Json = Chrome_trace. Json in
321- let ts = Time. now () |> Time. to_secs |> Event.Timestamp. of_float_seconds in
317+ let ts = make_ts ( Time. now () ) in
322318 let common = Event. common_fields ~cat: [ Category. to_string Gc ] ~name: " gc" ~ts () in
323319 let args =
324320 let stat = Gc. quick_stat () in
@@ -339,7 +335,7 @@ let gc () =
339335let fd_count () =
340336 let module Event = Chrome_trace. Event in
341337 let module Json = Chrome_trace. Json in
342- let ts = Time. now () |> Time. to_secs |> Event.Timestamp. of_float_seconds in
338+ let ts = make_ts ( Time. now () ) in
343339 match Fd_count. get () with
344340 | Unknown -> None
345341 | This fds ->
@@ -351,7 +347,7 @@ let fd_count () =
351347let promote src dst =
352348 let module Event = Chrome_trace. Event in
353349 let common =
354- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
350+ let ts = make_ts (Time. now () ) in
355351 Event. common_fields ~cat: [ Category. to_string Promote ] ~name: " promote" ~ts ()
356352 in
357353 let args =
@@ -380,7 +376,7 @@ let json_of_alias { dir; name; recursive; contexts } =
380376
381377let resolve_targets targets aliases =
382378 let module Event = Chrome_trace. Event in
383- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
379+ let ts = make_ts (Time. now () ) in
384380 let args =
385381 [ " targets" , List. map targets ~f: (fun p -> `String (Path. to_string p))
386382 ; " aliases" , List. map aliases ~f: json_of_alias
@@ -398,7 +394,7 @@ let resolve_targets targets aliases =
398394
399395let load_dir dir =
400396 let module Event = Chrome_trace. Event in
401- let ts = Event.Timestamp. of_float_seconds (Time. now () |> Time. to_secs ) in
397+ let ts = make_ts (Time. now () ) in
402398 let args = [ " dir" , `String (Path. to_string dir) ] in
403399 let common =
404400 Event. common_fields ~cat: [ Category. to_string Debug ] ~name: " load-dir" ~ts ()
0 commit comments