text stringlengths 12 786k |
|---|
type summary = { mutable samples : int ; subsums : summary StrTbl . t ; } |
let summary filename = let summary = { samples = 0 ; subsums = StrTbl . create 20 } in let count ( filenames , nsamples ) = let lastsum = List . fold_left ( fun sum f -> if StrTbl . mem sum . subsums f then StrTbl . find sum . subsums f else begin let s = { samples = 0 ; subsum... |
let ( ) = if Array . length Sys . argv <> 2 then Printf . fprintf stderr " Usage : % s < trace file >\ n " Sys . executable_name else summary Sys . argv . ( 1 ) |
let check_invariants program = try ( ) with exn -> Format . eprintf " Program which failed invariant check :@ % a \ n " %! Flambda_unit . print program ; raise exn |
module Outcome = struct type t = | Success | Failure | Error let to_exit_code = function | Success -> 0 | Failure when exit_normally_on_failure -> 0 | Failure -> 1 | Error -> 2 end |
module Test_outcome = struct type t = | Pass | Fail of { corrected : Fexpr . expect_test_spec } end |
let dump_error ( e : Parse_flambda . error ) = match e with | Parsing_error ( msg , loc ) -> Format . eprintf " % a . :@ Syntax error : % s . " @ Location . print_loc loc msg | Lexing_error ( error , loc ) -> Format . eprintf " % a . :@ Lex error : % a . " @ Locat... |
let run_expect_test ~ symbol_for_global ~ get_global_info ~ extension ~ filename ( { before ; after = expected } : Fexpr . expect_test_spec ) : Test_outcome . t = let comp_unit = Parse_flambda . make_compilation_unit ~ extension ~ filename ( ) in Compilation_unit . set_current comp_unit... |
let show_diff a b = let command_line = Filename . quote_command " diff " [ " - u " ; a ; b ] in let _exit_code = Sys . command command_line in ( ) |
let save_corrected ~ desc ~ print ~ orig_filename corrected = let corrected_filename = orig_filename ^ " . corrected " in Format . eprintf " Saving corrected % s as % s . " @ desc corrected_filename ; let corrected_out = open_out corrected_filename in Misc . try_finally ~ always ( : fun ... |
let run_flt_file filename : Outcome . t = match Parse_flambda . parse_expect_test_spec filename with | Ok test_spec -> begin match run_expect_test ~ symbol_for_global ~ get_global_info ~ extension " . : flt " ~ filename test_spec with | Pass -> Format . eprintf " PASS . " ; @ Success | ... |
let run_mdflx_file filename : Outcome . t = match Parse_flambda . parse_markdown_doc filename with | Ok doc -> let all_passed = ref true in let corrected_doc = List . map ( fun ( node : Fexpr . markdown_node ) : Fexpr . markdown_node -> match node with | Text _ -> node | Expect test_spec -... |
let _ = let file = Sys . argv . ( 1 ) in let ext = Filename . extension file in let outcome = match ext with | " . flt " -> run_flt_file file | " . mdflx " -> run_mdflx_file file | _ -> Misc . fatal_errorf " Unrecognized extension % s ; expected . flt or . mdflx " ext in ... |
[ @@@ ocaml . flambda_o3 ] [ @@@ ocaml . nolabels ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] |
let quiet_nan = nan = " caml_int64_float_of_bits " " caml_int64_float_of_bits_unboxed " [ @@ unboxed ] [ @@ noalloc ] |
let signaling_nan = float_of_bits 0x7F_F0_00_00_00_00_00_01L |
let is_finite ( x : float ) = x . - x = 0 . |
let is_infinite ( x : float ) = 1 . . / x = 0 . |
let is_nan ( x : float ) = x <> x |
type fpclass = Stdlib . fpclass = FP_normal | FP_subnormal | FP_zero | FP_infinite | FP_nan " caml_classify_float " " caml_classify_float_unboxed " [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ] [ @@ noalloc ] [ @@ unboxed ... |
let is_integer x = x = trunc x && is_finite x = " caml_nextafter_float " " caml_nextafter " [ @@ unboxed ] [ @@ noalloc ] |
let succ x = next_after x infinity |
let pred x = next_after x neg_infinity = " caml_copysign_float " " caml_copysign " [ @@ unboxed ] [ @@ noalloc ] = " caml_signbit_float " " caml_signbit " [ @@ noalloc ] " caml_ldexp_float " " caml_ldexp_float_unboxed " [ @@ noalloc ] |
let equal x y = compare x y = 0 if y > x || ( not ( sign_bit y ) && sign_bit x ) then if is_nan y then y else x else if is_nan x then x else y if y > x || ( not ( sign_bit y ) && sign_bit x ) then if is_nan x then x else y else if is_nan y then y else x if is_nan x || is_nan y then ( nan , ... |
let hash x = seeded_hash_param 10 100 0 x |
module Array = struct type t = floatarray external length : t -> int = " % floatarray_length " external get : t -> int -> float = " % floatarray_safe_get " external set : t -> int -> float -> unit = " % floatarray_safe_set " external create : int -> t = " caml_floatarray_create " ext... |
let equal ( x : float ) ( y : float ) = x , " " , = y , ( x = y ) |
let not_equal ( x : float ) ( y : float ) = x , " " , != y , ( x <> y ) |
let less_than ( x : float ) ( y : float ) = x , " " , < y , ( x < y ) |
let not_less_than ( x : float ) ( y : float ) = x , " " , !< y , not ( x < y ) |
let less_equal ( x : float ) ( y : float ) = x , " " , <= y , ( x <= y ) |
let not_less_equal ( x : float ) ( y : float ) = x , " " , !<= y , not ( x <= y ) |
let greater_than ( x : float ) ( y : float ) = x , " " , > y , ( x > y ) |
let not_greater_than ( x : float ) ( y : float ) = x , " " , !> y , not ( x > y ) |
let greater_equal ( x : float ) ( y : float ) = x , " " , >= y , ( x >= y ) |
let not_greater_equal ( x : float ) ( y : float ) = x , " " , !>= y , not ( x >= y ) |
let show ( x , op , y , b ) = print_float x ; print_string " " ; print_string op ; print_string " " ; print_float y ; print_string " : " ; print_endline ( string_of_bool b ) |
let print_line ( ) = print_endline " " ------------------ |
let ( ) = show ( equal 1 . 0 2 . 0 ) |
let ( ) = show ( equal 1 . 0 1 . 0 ) |
let ( ) = show ( equal 2 . 0 1 . 0 ) |
let ( ) = show ( equal 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( not_equal 1 . 0 2 . 0 ) |
let ( ) = show ( not_equal 1 . 0 1 . 0 ) |
let ( ) = show ( not_equal 2 . 0 1 . 0 ) |
let ( ) = show ( not_equal 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( less_than 1 . 0 2 . 0 ) |
let ( ) = show ( less_than 1 . 0 1 . 0 ) |
let ( ) = show ( less_than 2 . 0 1 . 0 ) |
let ( ) = show ( less_than 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( not_less_than 1 . 0 2 . 0 ) |
let ( ) = show ( not_less_than 1 . 0 1 . 0 ) |
let ( ) = show ( not_less_than 2 . 0 1 . 0 ) |
let ( ) = show ( not_less_than 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( less_equal 1 . 0 2 . 0 ) |
let ( ) = show ( less_equal 1 . 0 1 . 0 ) |
let ( ) = show ( less_equal 2 . 0 1 . 0 ) |
let ( ) = show ( less_equal 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( not_less_equal 1 . 0 2 . 0 ) |
let ( ) = show ( not_less_equal 1 . 0 1 . 0 ) |
let ( ) = show ( not_less_equal 2 . 0 1 . 0 ) |
let ( ) = show ( not_less_equal 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( greater_than 1 . 0 2 . 0 ) |
let ( ) = show ( greater_than 1 . 0 1 . 0 ) |
let ( ) = show ( greater_than 2 . 0 1 . 0 ) |
let ( ) = show ( greater_than 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( not_greater_than 1 . 0 2 . 0 ) |
let ( ) = show ( not_greater_than 1 . 0 1 . 0 ) |
let ( ) = show ( not_greater_than 2 . 0 1 . 0 ) |
let ( ) = show ( not_greater_than 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( greater_equal 1 . 0 2 . 0 ) |
let ( ) = show ( greater_equal 1 . 0 1 . 0 ) |
let ( ) = show ( greater_equal 2 . 0 1 . 0 ) |
let ( ) = show ( greater_equal 1 . 0 nan ) |
let ( ) = print_line ( ) |
let ( ) = show ( not_greater_equal 1 . 0 2 . 0 ) |
let ( ) = show ( not_greater_equal 1 . 0 1 . 0 ) |
let ( ) = show ( not_greater_equal 2 . 0 1 . 0 ) |
let ( ) = show ( not_greater_equal 1 . 0 nan ) |
let ( ) = print_line ( ) |
type t = { mutable f : float } |
let test x y = if Int64 . bits_of_float x . f <> y then printf " Error : bits_of_float % h <> 0x % Lx \ n " x . f y |
let _ = test { f = 0 . 0 } 0L ; test { f = ( - 0 . 0 ) } 0x8000000000000000L ; test { f = 0x1p - 3 } 0x3fc0000000000000L ; test { f = 0x1 . 1p - 3 } 0x3fc1000000000000L ; test { f = 0x1 . 2p - 3 } 0x3fc2000000000000L ; test { f = 0x1 . 3p - 3... |
type ' a t = { data : ' a array ; timestamps : Mtime . t array ; max_length : int ; mutable most_recently_added : int ; mutable length : int ; get_time : unit -> Mtime . t ; elt : ( module Integer . S with type t = ' a ) } |
let create ( type a ) ~ clock : get_time ~ size ~ elt : a t = if size <= 0 then Fmt . invalid_arg " Flow_meter . create : non - positive size % d " size ; let max_length = size + 1 in let start_time = get_time ( ) in { get_time ; data = Array . make max_length ( Obj . magic N... |
let is_empty t = t . most_recently_added = - 1 |
let push t ~ key ~ data = t . data . ( key ) <- data ; t . timestamps . ( key ) <- t . get_time ( ) |
let record t data = if t . length = t . max_length then ( let next = ( t . most_recently_added + 1 ) mod t . length in push t ~ key : next ~ data ; t . most_recently_added <- next ) else ( push t ~ key : t . length ~ data ; t . most_recently_added <- t . length ; t . lengt... |
let oldest_index t = if t . length = t . max_length then ( t . most_recently_added + 1 ) mod t . length else 0 |
let fold = let rec aux data f acc = function | - 1 -> acc | n -> aux data f ( f acc data . ( n ) ) ( n - 1 ) in fun t ~ f ~ init -> aux t . data f init ( t . length - 1 ) |
let per_second : type a . a t -> a = fun t -> let ( module Integer ) = t . elt in if is_empty t then Integer . zero else let oldest_index = oldest_index t in let sum = Integer . sub ( fold t ~ f : Integer . add ~ init : Integer . zero ) t . data . ( oldest_index ) in let interval ... |
let pp_ipair ppf ( x , y ) = pp ppf " ( % d % d ) " x y |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.