Skip to content

Commit

Permalink
v0.17~preview.128.37+01
Browse files Browse the repository at this point in the history
  • Loading branch information
public-release committed Aug 30, 2023
1 parent d153871 commit e524201
Show file tree
Hide file tree
Showing 317 changed files with 7,447 additions and 7,523 deletions.
1 change: 1 addition & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
profile=janestreet
6 changes: 3 additions & 3 deletions bench/example/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ module State_machine = struct
~sexp_of_action:[%sexp_of: Action.t]
~default_model:0
~apply_action:(fun (_ : _ Bonsai.Apply_action_context.t) model action ->
match action with
| Incr -> model + 1
| Decr -> model - 1)
match action with
| Incr -> model + 1
| Decr -> model - 1)
;;

let incr = Interaction.inject Action.Incr
Expand Down
10 changes: 5 additions & 5 deletions bench/src/cleanup.ml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ let invalidate_observers =
Core_bench_js.Test.create_with_initialization
~name:"cleaning up observers..."
(fun `init ->
(match !most_recent_driver with
| None -> ()
| Some (T driver) -> Runner.invalidate_observers driver);
most_recent_driver := None;
fun () -> ())
(match !most_recent_driver with
| None -> ()
| Some (T driver) -> Runner.invalidate_observers driver);
most_recent_driver := None;
fun () -> ())
;;
20 changes: 10 additions & 10 deletions bench/src/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ type ('a, 'r) unpacked =
type t = T : (_, _) unpacked -> t

let create
?(clock = Bonsai.Time_source.create ~start:Time_ns.epoch)
~name
~component
~get_inject
interaction
?(clock = Bonsai.Time_source.create ~start:Time_ns.epoch)
~name
~component
~get_inject
interaction
=
T { clock; name; component; get_inject; interaction }
;;

let create_with_resetter
?(clock = Bonsai.Time_source.create ~start:Time_ns.epoch)
~name
~component
~get_inject
interaction
?(clock = Bonsai.Time_source.create ~start:Time_ns.epoch)
~name
~component
~get_inject
interaction
=
T
{ clock
Expand Down
40 changes: 20 additions & 20 deletions bench/src/profile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ module Accumulated_measurement = struct
[@@deriving sexp]

let compare
{ kind; total_duration; _ }
{ kind = kind'; total_duration = total_duration'; _ }
{ kind; total_duration; _ }
{ kind = kind'; total_duration = total_duration'; _ }
=
match kind, kind' with
| Named _, Named _ -> Float.descending total_duration total_duration'
Expand Down Expand Up @@ -135,12 +135,12 @@ let create_snapshot_table data ~incremental_time =
; Column.create
"Total time (ms)"
(fun { Accumulated_measurement.total_duration; _ } ->
Float.to_string total_duration)
Float.to_string total_duration)
; Column.create
"Percent of incremental time"
(fun { Accumulated_measurement.total_duration; _ } ->
Percent.Always_percentage.to_string
(Percent.of_percentage (total_duration /. incremental_time *. 100.)))
Percent.Always_percentage.to_string
(Percent.of_percentage (total_duration /. incremental_time *. 100.)))
]
in
to_string_noattr columns data ~limit_width_to:Int.max_value ~bars:`Unicode
Expand Down Expand Up @@ -177,8 +177,8 @@ let print_statistics data =
;;

let accumulate_measurements
~(source_locations : Graph_info.Node_info.t Bonsai.Private.Node_path.Map.t)
measurements
~(source_locations : Graph_info.Node_info.t Bonsai.Private.Node_path.Map.t)
measurements
=
let with_ids, without_ids =
List.map measurements ~f:(fun measurement ->
Expand All @@ -199,14 +199,14 @@ let accumulate_measurements
|> List.fold
~init:(Int.Map.empty, Measurement.Kind.Map.empty)
~f:(fun (with_ids, without_ids) measurement ->
let accumulate_measurements = function
| None -> Accumulated_measurement.of_measurement measurement
| Some accumulated -> Accumulated_measurement.add accumulated ~measurement
in
match measurement.id with
| None ->
with_ids, Map.update without_ids measurement.kind ~f:accumulate_measurements
| Some id -> Map.update with_ids id ~f:accumulate_measurements, without_ids)
let accumulate_measurements = function
| None -> Accumulated_measurement.of_measurement measurement
| Some accumulated -> Accumulated_measurement.add accumulated ~measurement
in
match measurement.id with
| None ->
with_ids, Map.update without_ids measurement.kind ~f:accumulate_measurements
| Some id -> Map.update with_ids id ~f:accumulate_measurements, without_ids)
in
Map.fold without_ids ~init:with_ids ~f:(fun ~key:_ ~data:measurement acc ->
let id =
Expand Down Expand Up @@ -258,7 +258,7 @@ let profile (T { clock; component; get_inject; interaction; name } : Config.t) =
let label = Js.to_string entry##.name in
let duration = entry##.duration in
performance_entries
:= Measurement.create ~label ~duration :: !performance_entries))
:= Measurement.create ~label ~duration :: !performance_entries))
else
failwith
"PerformanceObserver could not be found. Please reach out to webdev-public on \
Expand All @@ -275,10 +275,10 @@ let profile (T { clock; component; get_inject; interaction; name } : Config.t) =
~wrap_driver_creation:
{ f =
(fun create_driver ->
Measurement.mark_before Startup;
let driver = create_driver () in
Measurement.mark_after_and_measure Startup;
driver)
Measurement.mark_before Startup;
let driver = create_driver () in
Measurement.mark_after_and_measure Startup;
driver)
}
~clock
~component
Expand Down
18 changes: 9 additions & 9 deletions bench/src/runner.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ let dedup_stabilizations interactions =
[Stabilize]s don't add anything to benchmarks and would add a function call of
overhead. *)
let initialize
~filter_profiles
~wrap_driver_creation
~clock
~component
~get_inject
~interaction
~filter_profiles
~wrap_driver_creation
~clock
~component
~get_inject
~interaction
=
let driver = wrap_driver_creation.f (fun () -> Bonsai_driver.create ~clock component) in
let inject_action action =
Expand All @@ -68,9 +68,9 @@ let initialize
]
|> flatten_interactions_to_list
|> List.filter ~f:(fun interaction ->
match filter_profiles, interaction with
| true, Profile _ -> false
| _ -> true)
match filter_profiles, interaction with
| true, Profile _ -> false
| _ -> true)
|> dedup_stabilizations
|> Array.of_list
in
Expand Down
38 changes: 22 additions & 16 deletions bindings/dygraph/src/area.ml
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
[@@@js.dummy "!! This code has been generated by gen_js_api !!"]
[@@@ocaml.warning "-7-32-39"]

open! Core
open! Import
open Gen_js_api
type t = {
x: int ;
y: int ;
w: int ;
h: int }

type t =
{ x : int
; y : int
; w : int
; h : int
}

let rec t_of_js : Ojs.t -> t =
fun (x2 : Ojs.t) ->
{
x = (Ojs.int_of_js (Ojs.get_prop_ascii x2 "x"));
y = (Ojs.int_of_js (Ojs.get_prop_ascii x2 "y"));
w = (Ojs.int_of_js (Ojs.get_prop_ascii x2 "w"));
h = (Ojs.int_of_js (Ojs.get_prop_ascii x2 "h"))
}
{ x = Ojs.int_of_js (Ojs.get_prop_ascii x2 "x")
; y = Ojs.int_of_js (Ojs.get_prop_ascii x2 "y")
; w = Ojs.int_of_js (Ojs.get_prop_ascii x2 "w")
; h = Ojs.int_of_js (Ojs.get_prop_ascii x2 "h")
}

and t_to_js : t -> Ojs.t =
fun (x1 : t) ->
Ojs.obj
[|("x", (Ojs.int_to_js x1.x));("y", (Ojs.int_to_js x1.y));("w",
(Ojs.int_to_js
x1.w));
("h", (Ojs.int_to_js x1.h))|]
Ojs.obj
[| "x", Ojs.int_to_js x1.x
; "y", Ojs.int_to_js x1.y
; "w", Ojs.int_to_js x1.w
; "h", Ojs.int_to_js x1.h
|]
;;
2 changes: 1 addition & 1 deletion bindings/dygraph/src/area.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open! Core
open! Import
open Gen_js_api
open Gen_js_api

(** An object with {x,y,w,h} properties describing the drawing area, for use in
[underlayCallback]. All units are in pixels (I think). *)
Expand Down
6 changes: 3 additions & 3 deletions bindings/dygraph/src/canvas_rendering_context_2D.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open! Core
open Import
open Import

include Js_obj.Make (struct
type t = Dom_html.canvasRenderingContext2D
end)
type t = Dom_html.canvasRenderingContext2D
end)
2 changes: 1 addition & 1 deletion bindings/dygraph/src/canvas_rendering_context_2D.mli
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
open! Core
open Import
open Import
include Js_obj.S with type t = Dom_html.canvasRenderingContext2D Js.t
2 changes: 1 addition & 1 deletion bindings/dygraph/src/color.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open! Core
open! Import
open Gen_js_api
open Gen_js_api

type t = Css_gen.Color.t [@@deriving sexp]

Expand Down
2 changes: 1 addition & 1 deletion bindings/dygraph/src/color.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
open! Core
open! Import
open Gen_js_api
open Gen_js_api

type t = Css_gen.Color.t [@@deriving sexp]

Expand Down
26 changes: 13 additions & 13 deletions bindings/dygraph/src/data.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ open Gen_js_api

type t = Ojs.t

let t_to_js x = x
let create data = Ojs.array_to_js (Ojs.array_to_js Ojs.float_to_js) data
let t_to_js x = x
let create data = Ojs.array_to_js (Ojs.array_to_js Ojs.float_to_js) data

let create' data ~x_to_js ~y_to_js =
let row_to_js (x, data) =
Expand Down Expand Up @@ -55,11 +55,11 @@ let create_from_independent_series' ~min ~equal series =
let next_x () =
Array.fold2_exn ~init:None current_idxes series ~f:(fun earliest_x idx series ->
match safe_get series ~idx with
| None -> earliest_x
| None -> earliest_x
| Some (x, _) ->
Some
(match earliest_x with
| None -> x
| None -> x
| Some earliest_x -> min x earliest_x))
in
(* This loop will make an array (in chronological order) of:
Expand All @@ -69,13 +69,13 @@ let create_from_independent_series' ~min ~equal series =
*)
let rec loop ~data_acc =
match next_x () with
| None -> Array.of_list_rev data_acc
| None -> Array.of_list_rev data_acc
| Some next_x ->
let next_row =
Array.mapi series ~f:(fun i series ->
let idx = current_idxes.(i) in
match safe_get series ~idx with
| None -> None
| None -> None
| Some (x, value) ->
if equal x next_x
then (
Expand Down Expand Up @@ -104,15 +104,15 @@ let create_from_independent_time_series series =
;;

let%expect_test "test [create_from_independent_time_series]" =
let t1 = Time_ns.epoch in
let t2 = Time_ns.add t1 Time_ns.Span.day in
let t3 = Time_ns.add t2 Time_ns.Span.day in
let t4 = Time_ns.add t3 Time_ns.Span.day in
let ts1 = [| t1, 1.; t3, 3. |] in
let ts2 = [| t2, 2.; t3, 3.; t4, 4. |] in
let t1 = Time_ns.epoch in
let t2 = Time_ns.add t1 Time_ns.Span.day in
let t3 = Time_ns.add t2 Time_ns.Span.day in
let t4 = Time_ns.add t3 Time_ns.Span.day in
let ts1 = [| t1, 1.; t3, 3. |] in
let ts2 = [| t2, 2.; t3, 3.; t4, 4. |] in
create_from_independent_time_series' [| ts1; ts2 |]
|> Array.iter ~f:(fun row ->
[%sexp_of: Time_ns.Alternate_sexp.t * float option array] row |> print_s);
[%sexp_of: Time_ns.Alternate_sexp.t * float option array] row |> print_s);
[%expect
{|
("1970-01-01 00:00:00Z" ((1) ()))
Expand Down
6 changes: 3 additions & 3 deletions bindings/dygraph/src/data.mli
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ val create_option : (float * float option array) array -> t
Remember to include the following script when using the Timezone libaray:
<script type="text/javascript" src="https://timezone-web/timezone-web/all-tz-v1.js"></script>
*)
val create_date : (Date.t * float array) array -> zone:Timezone.t -> t
val create_date : (Date.t * float array) array -> zone:Timezone.t -> t

(** [create_time_ns] is for when your x-values are times. *)
val create_time_ns : (Time_ns.t * float array) array -> t
val create_time_ns : (Time_ns.t * float array) array -> t

(** [create_time_ns_option] is for when your x-values are times and your y-values are options. *)
val create_time_ns_option : (Time_ns.t * float option array) array -> t
Expand All @@ -40,5 +40,5 @@ val create_time_ns_option : (Time_ns.t * float option array) array -> t
[Ts_server_protocol_kernel.Time_series_data.transpose].
*)

val create_from_independent_series : (float * float) array array -> t
val create_from_independent_series : (float * float) array array -> t
val create_from_independent_time_series : (Time_ns.t * float) array array -> t
Loading

0 comments on commit e524201

Please sign in to comment.