text stringlengths 0 601k |
|---|
let of_sexp = Of_sexp . ( wrap_of_sexp of_sexp ) |
module Utils = struct let flatten_month_ranges ( months : int range Seq . t ) : int Seq . t option = try Some ( Month_ranges . Flatten . flatten months ) with Range . Range_is_invalid -> None let flatten_month_range_list ( months : int range list ) : int list option = try Some ( Month_ranges . Flatten . flatten_list mo... |
type t = { mutable main : int ; mutable sub : int ; mutable div_c : int ; mutable tima : Uint8 . t ; mutable div : Uint8 . t ; mutable tma : Uint8 . t ; mutable tac : Uint8 . t ; } |
let make ( ) = { main = 0 ; sub = 0 ; div_c = 0 ; div = Uint8 . zero ; tima = Uint8 . zero ; tma = Uint8 . zero ; tac = Uint8 . zero ; } |
let get_mode { tac ; _ } = if Uint8 . code tac land 4 != 0 then match Uint8 . code tac land 3 with | 0 -> Some 64 | 1 -> Some 1 | 2 -> Some 4 | 3 -> Some 16 | _ -> None else None |
let tick t m_cycles = t . sub <- t . sub + m_cycles ; if t . sub >= 4 then begin t . main <- succ t . main ; t . sub <- t . sub - 4 ; t . div_c <- succ t . div_c ; if t . div_c == 16 then begin t . div <- Uint8 . succ t . div ; t . div_c <- 0 end end ; match get_mode t with | None -> false | Some threshold when t . mai... |
let config = { Scheduler . Config . concurrency = 1 ; display = { verbosity = Short ; status_line = false } ; rpc = None ; stats = None } Scheduler . Run . go ~ on_event ( : fun _ _ -> ( ) ) config ( fun ( ) -> let now ( ) = Unix . gettimeofday ( ) in let start = now ( ) in let duration = 0 . 2 in let + ( ) = Scheduler... |
let int64_pow b n = let rec loop b n acc = if n = 0 then acc else loop Int64 . ( mul b b ) ( n lsr 1 ) ( if n land 1 = 0 then acc else Int64 . ( mul b acc ) ) in loop b n 1L |
let pp = Ptime . pp_human ~ frac_s : 6 ( ) |
let of_string x = let d_ps_of_intlit intlit = let sec = Int64 . of_string intlit in let d = Int64 . div sec 86_400L in let ps = Int64 . ( mul ( rem sec 86_400L ) 1_000_000_000_000L ) in ( Int64 . to_int d , ps ) in match match String . split_on_char ' . ' x with | [ _ ] -> Ptime . Span . of_d_ps ( d_ps_of_intlit x ) | ... |
let to_string ts = let d , ps = Ptime . Span . to_d_ps ( Ptime . diff ts Ptime . epoch ) in let sec = Int64 . ( add ( mul ( of_int d ) 86_400L ) ( div ps 1_000_000_000_000L ) ) in let subsec = Int64 . ( rem ps 1_000_000_000_000L ) in Printf . sprintf " % Ld . % 06Ld " sec ( Int64 . div subsec 1_000_000L ) |
let of_yojson json = match match json with | ` Int x -> Ptime . of_span ( Ptime . Span . of_int_s x ) | ` Intlit x -> of_string x | ` String x -> of_string x | _ -> None with | Some ts -> Result . Ok ts | None -> Result . Error " Couldn ' t parse timestamp " |
let to_yojson ts = ` String ( to_string ts ) |
module type Extend_zone = Timezone_intf . Extend_zone |
module Zone_cache = struct type z = { mutable full : bool ; basedir : string ; table : t String . Table . t } let the_one_and_only = { full = false ; basedir = Option . value ( Sys . getenv_opt " TZDIR " ) ~ default " :/ usr / share / zoneinfo " / ; table = String . Table . create ( ) } ; ; let find zone = Hashtbl . fi... |
let find zone = let zone = match zone with | " utc " -> " UTC " | " gmt " -> " GMT " | " chi " -> " America / Chicago " | " nyc " -> " America / New_York " | " hkg " -> " Asia / Hong_Kong " | " lon " | " ldn " -> " Europe / London " | " tyo " -> " Asia / Tokyo " | _ -> zone in Zone_cache . find_or_load zone ; ; |
let find_exn zone = match find zone with | None -> Error . raise_s [ % message " unknown zone " ( zone : string ) ] | Some z -> z ; ; |
let local = let local_zone_name = Sys . getenv_opt " TZ " in let load ( ) = match local_zone_name with | Some zone_name -> find_exn zone_name | None -> let localtime_t = input_tz_file ~ zonename " :/ etc / localtime " ~ filename " :/ etc / localtime " in ( match Zone_cache . find_or_load_matching localtime_t with | Som... |
module Stable = struct include Core_kernel_private . Time_zone . Stable module V1 = struct type nonrec t = t let t_of_sexp sexp = match sexp with | Sexp . Atom " Local " -> Lazy . force local | Sexp . Atom name -> ( try if String . is_prefix name ~ prefix " : GMT " - || String . is_prefix name ~ prefix " : GMT " + || S... |
module Private = struct module Zone_cache = Zone_cache end |
module type Extend_zone = sig type t include Identifiable . S with type t := t val find : string -> t option val find_exn : string -> t val local : t Lazy . t val initialized_zones : unit -> ( string * t ) list val init : unit -> unit end |
module type Timezone = sig module type Extend_zone = Extend_zone include Core_kernel_private . Time_zone . S with type t = Time . Zone . t include Extend_zone with type t := t module Stable : sig module V1 : sig type nonrec t = t [ @@ deriving bin_io , compare , hash , sexp ] end include Core_kernel_private . Time_zone... |
type unary_op = | Not | Shift of Timedesc . Span . t | Lengthen of Timedesc . Span . t | With_tz of Timedesc . Time_zone . t |
type chunking = [ ` Disjoint_intervals | ` By_duration of Timedesc . Span . t | ` By_duration_drop_partial of Timedesc . Span . t | ` At_year_boundary | ` At_month_boundary ] |
type chunked_unary_op_on_t = | Chunk_disjoint_interval | Chunk_at_year_boundary | Chunk_at_month_boundary | Chunk_by_duration of { chunk_size : Timedesc . Span . t ; drop_partial : bool ; } |
type chunked_unary_op_on_chunked = | Drop of int | Take of int | Take_nth of int | Nth of int | Chunk_again of chunked_unary_op_on_t |
type t = | Empty | All | Intervals of ( Timedesc . Span . t * Timedesc . Span . t ) Seq . t | ISO_week_pattern of Int_set . t * Int_set . t | Pattern of Pattern . t | Unary_op of unary_op * t | Inter_seq of t Seq . t | Union_seq of t Seq . t | Pattern_intervals of { mode : [ ` Whole_inc | ` Whole_exc | ` Fst | ` Snd ] ... |
module type S = sig type t include Binable . S with type t := t include Comparable . S with type t := t include Hashable . S with type t := t include Sexpable . S with type t := t include Stringable . S with type t := t module Span : sig type t include Binable . S with type t := t include Comparable . S with type t := ... |
module type S_kernel_without_zone = Time0_intf . S |
module type S_kernel = Time_intf . S |
module Stable = struct include Time_float0 . Stable module With_utc_sexp = struct module V2 = struct type nonrec t = t [ @@ deriving bin_io , compare , hash ] let sexp_of_t t = [ % sexp ( to_string_abs_parts t ~ zone : Zone . utc : string list ) ] let t_of_sexp sexp = try match sexp with | Sexp . List [ Sexp . Atom dat... |
module Absolute = struct type underlying = Float . t include ( Float : sig type t = float [ @@ deriving bin_io , hash , typerep ] include Comparable . S_common with type t := t include module type of struct include Float . O end end ) include Float . Robust_compare . Make ( struct let robust_comparison_tolerance = 1E -... |
module Date_and_ofday = struct type t = float let of_synthetic_span_since_epoch span = Span . to_sec span let to_synthetic_span_since_epoch t = Span . of_sec t let of_date_ofday date ofday = let days = Float . of_int ( Date0 . Days . diff ( Date0 . Days . of_date date ) Date0 . Days . unix_epoch ) in ( days . * 86400 .... |
let next_multiple_internal ~ can_equal_after ~ base ~ after ~ interval = if Span . ( <= ) interval Span . zero then failwiths ~ here [ :% here ] " Time . next_multiple got nonpositive interval " interval [ % sexp_of : Span . t ] ; let base_to_after = diff after base in if Span . ( < ) base_to_after Span . zero then bas... |
let next_multiple ( ? can_equal_after = false ) ~ base ~ after ~ interval ( ) = next_multiple_internal ~ can_equal_after ~ base ~ after ~ interval ; ; |
let prev_multiple ( ? can_equal_before = false ) ~ base ~ before ~ interval ( ) = next_multiple_internal ~ can_equal_after ( : not can_equal_before ) ~ base ~ after ( : sub before interval ) ~ interval ; ; |
let now ( ) = let float_ns = Time_now . nanoseconds_since_unix_epoch ( ) |> Int63 . to_float in of_span_since_epoch ( Span . of_sec ( float_ns . * 1E - 9 ) ) ; ; |
module Stable = struct module Span = Span . Stable module Ofday = Ofday . Stable end |
module Int64_set = Set . Make ( struct type t = int64 let compare = compare end ) |
module Span_set = Diet . Make ( struct type t = Timedesc . Span . t let compare = Timedesc . Span . compare let zero = Timedesc . Span . zero let pred = Timedesc . Span . pred let succ = Timedesc . Span . succ let sub = Timedesc . Span . sub let add = Timedesc . Span . add let to_string = Timedesc . Span . to_string en... |
module Alco = struct let suite = [ ] end |
module Qc = struct let slice_start = QCheck . Test . make ~ count : 10_000 ~ name " : slice_start " QCheck . ( pair pos_timestamp sorted_time_slots_maybe_gaps ) ( fun ( start , l ) -> l |> CCList . to_seq |> Time . Intervals . Slice . slice ~ start |> OSeq . for_all ( fun ( x , _ ) -> Timedesc . Span . ( start <= x ) )... |
module type Zone = sig module Time : Time0_intf . S include Zone . S with type t = Zone . t and module Time_in_seconds := Time val abbreviation : t -> Time . t -> string val absolute_time_of_date_and_ofday : t -> Time . Date_and_ofday . t -> Time . t val date_and_ofday_of_absolute_time : t -> Time . t -> Time . Date_an... |
module type Basic = sig module Time : Time0_intf . S include module type of struct include Time end [ @ ocaml . remove_aliases ] val now : unit -> t module Zone : Zone with module Time := Time val add : t -> Span . t -> t val sub : t -> Span . t -> t val diff : t -> t -> Span . t val abs_diff : t -> t -> Span . t end |
module type Shared = sig type t include Quickcheck . S_range with type t := t module Span : sig type t end module Ofday : sig type t end val is_earlier : t -> than : t -> bool val is_later : t -> than : t -> bool val of_date_ofday : zone : Zone . t -> Date . t -> Ofday . t -> t val of_date_ofday_precise : Date . t -> O... |
module type S = sig include Basic include Shared with type t := t with module Span := Span with module Ofday := Ofday end |
module type Time = sig module type S = S module Make ( Time : Time0_intf . S ) : S with module Time := Time end |
module type S = sig val duration : Measurement . key -> ( unit -> ' a ) -> ' a val duration_lwt : Measurement . key -> ( unit -> ' a Lwt . t ) -> ' a Lwt . t val timestamp_pre : Measurement . key -> ( unit -> ' a ) -> ' a val flush : unit -> unit Lwt . t end |
module Make ( S : State . S with type elt := Measurement . t ) ( P : Publisher . S ) ( C : Clock . S ) : S = struct let span start stop = stop . - start let duration ( label , metadata ) f = let start = C . current_time ( ) in let res = f ( ) in let stop = C . current_time ( ) in let duration = span start stop in let m... |
let arch_sixtyfour = Sys . word_size = 64 |
let add = Span . ( + ) |
let sub = Span . ( - ) |
let diff = Span . ( - ) |
let abs_diff t u = Span . abs ( diff t u ) |
let to_span_since_epoch t = t |
let of_span_since_epoch s = s |
let to_int63_ns_since_epoch t : Int63 . t = Span . to_int63_ns ( to_span_since_epoch t ) |
let of_int63_ns_since_epoch i = of_span_since_epoch ( Span . of_int63_ns i ) |
let is_earlier t1 ~ than : t2 = t1 < t2 |
let is_later t1 ~ than : t2 = t1 > t2 |
let add_overflowed x y ~ sum = if Span . ( > ) y Span . zero then Span . ( < ) sum x else Span . ( > ) sum x ; ; |
let sub_overflowed x y ~ diff = if Span . ( > ) y Span . zero then Span . ( > ) diff x else Span . ( < ) diff x ; ; |
let add_exn x y = let sum = add x y in if add_overflowed x y ~ sum then overflow ( ) else sum ; ; |
let sub_exn x y = let diff = sub x y in if sub_overflowed x y ~ diff then overflow ( ) else diff ; ; |
let add_saturating x y = let sum = add x y in if add_overflowed x y ~ sum then if Span . ( y > zero ) then Span . max_value_representable else Span . min_value_representable else sum ; ; |
let sub_saturating x y = let diff = sub x y in if sub_overflowed x y ~ diff then if Span . ( y > zero ) then Span . min_value_representable else Span . max_value_representable else diff ; ; |
let to_int_ns_since_epoch = if arch_sixtyfour then fun t -> Int63 . to_int_exn ( to_int63_ns_since_epoch t ) else fun _ -> failwith " Time_ns . to_int_ns_since_epoch : unsupported on 32bit machines " ; ; |
let of_int_ns_since_epoch i = of_int63_ns_since_epoch ( Int63 . of_int i ) |
let to_time_float_round_nearest t = Time_float . of_span_since_epoch ( Span . to_span_float_round_nearest ( to_span_since_epoch t ) ) ; ; |
let to_time_float_round_nearest_microsecond t = Time_float . of_span_since_epoch ( Span . to_span_float_round_nearest_microsecond ( to_span_since_epoch t ) ) ; ; |
let min_time_value_for_1us_rounding = to_time_float_round_nearest min_value_for_1us_rounding ; ; |
let max_time_value_for_1us_rounding = to_time_float_round_nearest max_value_for_1us_rounding ; ; |
let check_before_conversion_for_1us_rounding time = if Time_float . ( < ) time min_time_value_for_1us_rounding || Time_float . ( > ) time max_time_value_for_1us_rounding then failwiths ~ here [ :% here ] " Time_ns does not support this time " time [ % sexp_of : Time_float . Stable . With_utc_sexp . V2 . t ] ; ; |
let of_time_float_round_nearest time = of_span_since_epoch ( Span . of_span_float_round_nearest ( Time_float . to_span_since_epoch time ) ) ; ; |
let of_time_float_round_nearest_microsecond time = check_before_conversion_for_1us_rounding time ; of_span_since_epoch ( Span . of_span_float_round_nearest_microsecond ( Time_float . to_span_since_epoch time ) ) ; ; failwiths ~ here [ :% here ] " Time_ns . next_multiple got nonpositive interval " interval [ % sexp_of :... |
let next_multiple_internal ~ can_equal_after ~ base ~ after ~ interval = if Span . ( <= ) interval Span . zero then raise_next_multiple_got_nonpositive_interval interval ; let base_to_after = diff after base in if Span . ( < ) base_to_after Span . zero then base else ( let next = add base ( Span . scale_int63 interval ... |
let next_multiple ( ? can_equal_after = false ) ~ base ~ after ~ interval ( ) = next_multiple_internal ~ can_equal_after ~ base ~ after ~ interval ; ; |
let prev_multiple ( ? can_equal_before = false ) ~ base ~ before ~ interval ( ) = next_multiple_internal ~ can_equal_after ( : not can_equal_before ) ~ base ~ after ( : sub before interval ) ~ interval ; ; |
let random ? state ( ) = Span . random ? state ( ) |
module Utc : sig val to_date_and_span_since_start_of_day : t -> Date0 . t * Span . t val of_date_and_span_since_start_of_day : Date0 . t -> Span . t -> t let to_date_and_span_since_start_of_day t = let open Int63 . O in let ( !< ) i = Int63 . of_int_exn i in let ( !> ) t = Int63 . to_int_exn t in let ns_since_epoch = t... |
module Alternate_sexp = struct type nonrec t = t module Ofday_as_span = struct open Int . O let seconds_to_string seconds_span = let seconds = Span . to_int_sec seconds_span in let h = seconds / 3600 in let m = seconds / 60 % 60 in let s = seconds % 60 in sprintf " % 02d :% 02d :% 02d " h m s ; ; let two_digit_of_strin... |
module Stable = struct module Alternate_sexp = Alternate_sexp . Stable module Span = Span . Stable module Ofday = Ofday . Stable end |
module To_and_of_string : sig val of_date_ofday : zone : Zone . t -> Date . t -> Ofday . t -> t val of_date_ofday_precise : Date . t -> Ofday . t -> zone : Zone . t -> [ ` Once of t | ` Twice of t * t | ` Never of t ] val to_date_ofday : t -> zone : Zone . t -> Date . t * Ofday . t val to_date_ofday_precise : t -> zone... |
let min_value_representable = of_span_since_epoch Span . min_value_representable |
let max_value_representable = of_span_since_epoch Span . max_value_representable |
module For_ppx_module_timer = struct open Ppx_module_timer_runtime let ( ) = Duration . format := ( module struct let duration_of_span s = s |> Span . to_int63_ns |> Duration . of_nanoseconds let span_of_duration d = d |> Duration . to_nanoseconds |> Span . of_int63_ns let of_string string = string |> Span . of_string ... |
module type Span = sig type t = private Int63 . t [ @@ deriving hash ] include Span_intf . S with type underlying = Int63 . t and type t := t val of_sec_with_microsecond_precision : float -> t val of_int_us : int -> t val of_int_ms : int -> t val to_int_us : t -> int val to_int_ms : t -> int val to_int_sec : t -> int v... |
module type Ofday = sig module Span : Span type t = private Int63 . t include Ofday_intf . S with type underlying = Int63 . t and type t := t and module Span := Span val approximate_end_of_day : t val add_exn : t -> Span . t -> t val sub_exn : t -> Span . t -> t val every : Span . t -> start : t -> stop : t -> t list O... |
module type Time_ns = sig module Span : Span module Ofday : Ofday with module Span := Span type t = private Int63 . t [ @@ deriving hash , typerep , bin_io ] include Comparisons . S with type t := t module Alternate_sexp : sig type nonrec t = t [ @@ deriving sexp ] end include Time_intf . Shared with type t := t with m... |
let x = Tezos_time_measurement_runtime . Default . Time_measurement . duration " label42 " ( fun ( ) -> 40 + 2 ) ] } ) * |
type measurement_key = { label : string ; metadata : expression Option . t } |
type rewriter = | Duration of measurement_key * location | Duration_lwt of measurement_key * location | Timestamp_pre of measurement_key * location | Flush of location |
type rewriter_constants = { fn_name : string ; attribute_name : string } |
let duration key loc = Duration ( key , loc ) |
let duration_lwt key loc = Duration_lwt ( key , loc ) |
let timestamp_pre key loc = Timestamp_pre ( key , loc ) |
let flush loc = Flush loc |
let create_rewriter_constants fn_name = let namespaced name = " time " ^ " . " ^ name in { fn_name ; attribute_name = namespaced fn_name } |
let duration_constants = create_rewriter_constants " duration " |
let duration_lwt_constants = create_rewriter_constants " duration_lwt " |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.