package bonsai

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file test_lifecycle_path_length.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
open! Core
open Bonsai_web_test
open Bonsai_test_of_bonsai_itself.Big_computation_regression_util

let%test_module "Comparing path id lengths to demonstrate potential cause of slowness." =
  (module struct
    let%expect_test "Proc Syntax" =
      let handle = Handle.create values_result_spec (For_proc.basic ~height:5 ~width:7) in
      Handle.show handle;
      [%expect
        {|
        (bonsai_path_x bonsai_path_y_x bonsai_path_y_y_x bonsai_path_y_y_y_x
         bonsai_path_y_y_y_y_x bonsai_path_y_y_y_y_y)
        |}];
      let handle =
        Handle.create lengths_result_spec (For_proc.basic ~height:5 ~width:7)
      in
      Handle.show handle;
      [%expect {| (13 15 17 19 21 21) |}]
    ;;

    let%expect_test "Cont Syntax" =
      let () =
        try
          let handle =
            Handle.create values_result_spec (For_cont.basic ~height:5 ~width:7)
          in
          Handle.show handle
        with
        | exn ->
          Option.iter (Js_of_ocaml.Js_error.of_exn exn) ~f:(fun js_error ->
            print_endline (Js_of_ocaml.Js_error.to_string js_error))
      in
      (* NOTE: Paths in cont are really big. We believe this is making <app-name> ~50 times
         slower after having been migrated to the CONT API. *)
      [%expect
        {|
        (bonsai_path_x_x bonsai_path_x_y bonsai_path_y_x_x bonsai_path_y_x_y
         bonsai_path_y_y_x bonsai_path_y_y_y)
        |}];
      let (_ : _) = [%expect.output] in
      [%expect {| |}];
      let handle =
        Handle.create lengths_result_spec (For_cont.basic ~height:5 ~width:7)
      in
      Handle.show handle;
      [%expect {| (15 15 17 17 17 17) |}]
    ;;
  end)
;;

let%test_module "Comparing path id lengths bigger example" =
  (module struct
    let%expect_test "Proc Syntax" =
      let handle =
        Handle.create lengths_result_spec (For_proc.basic ~height:10 ~width:7)
      in
      Handle.show handle;
      [%expect {| (13 15 17 19 21 23 25 27 29 31 31) |}]
    ;;

    let%expect_test "Cont Syntax" =
      let handle =
        Handle.create lengths_result_spec (For_cont.basic ~height:10 ~width:7)
      in
      Handle.show handle;
      [%expect {| (17 17 19 19 17 19 19 17 17 19 19) |}]
    ;;
  end)
;;