Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file display_units.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158openCoreopenPolytypet=|Words|Time|Gc|Cycles|Count|Percentageletdisplay_minimum=function|Words->0.1|Time->0.01|Gc->1E-5|Cycles->1.0|Count->0.01|Percentage->0.0001;;(* 100%=1., not 100.*)moduleMagnitude=structtypet=|One|Kilo|Mega|Giga|Milli|Micro|Nanoletmax=Gigaletmagnitude_ignoring_minimumv=letv=Float.absvinifv<1E-6thenNanoelseifv<1E-3thenMicroelseifv<1.0thenMillielseifv<1E3thenOneelseifv<1E6thenKiloelseifv<1E9thenMegaelseGiga;;letmagnitudeunitv=letv=Float.absvinifv<display_minimumunitthenGigaelsemagnitude_ignoring_minimumv;;letfloat_hum~decimalssuffixdivv=Float.to_string_hum~decimals(v/.div)^suffixletf2ssuffixdivv=float_hum~decimals:2suffixdivvletto_string_nanos=function|Nano->f2s"e-9ns"1E-9|Micro->f2s"e-6ns"1E-6|Milli|One->f2s"ns"1.0|Kilo->f2s"us"1E3|Mega->f2s"ms"1E6|Giga->f2s"s"1E9;;letto_string_cycles=function|Nano->f2s"e-9c"1E-9|Micro->f2s"e-6c"1E-6|Milli|One->f2s"c"1.0|Kilo->f2s"kc"1E3|Mega->f2s"Mc"1E6|Giga->f2s"Gc"1E9;;letto_string_words=function|Nano->f2s"e-9w"1E-9|Micro->f2s"e-6w"1E-6|Milli|One->f2s"w"1.0|Kilo->f2s"kw"1E3|Mega->f2s"Mw"1E6|Giga->f2s"Gw"1E9;;letto_string_count=function|Nano->f2s"e-9"1E-9|Micro->f2s"e-6"1E-6|Milli->f2s"e-3"1E-3|One->f2s""1.0|Kilo->f2s"k"1E3|Mega->f2s"M"1E6|Giga->f2s"G"1E9;;letto_string_gc=function|Nano->f2s"e-9"1E-9|Micro|Milli->f2s"e-3"1E-3|One->f2s""1.0|Kilo->f2s"k"1E3|Mega->f2s"M"1E6|Giga->f2s"G"1E9;;letto_string_percentage_=f2s"%"1E-2letsmallert1t2=matcht1,t2with|Nano,_|_,Nano->Nano|Micro,_|_,Micro->Micro|Milli,_|_,Milli->Milli|One,_|_,One->One|Kilo,_|_,Kilo->Kilo|Mega,_|_,Mega->Mega|_,_->Giga;;endletis_displayed~show_all_valuestv=show_all_values||Float.absv>display_minimumtletis_displayed_opt~show_all_valuestv=matchvwith|Somev->is_displayed~show_all_valuestv|None->false;;letto_string~show_all_valuestexpv:Ascii_table_kernel.Attr.tlist*string=letto_string=function|Words->Magnitude.to_string_words|Time->Magnitude.to_string_nanos|Gc->Magnitude.to_string_gc|Cycles->Magnitude.to_string_cycles|Count->Magnitude.to_string_count|Percentage->Magnitude.to_string_percentageinifis_displayed~show_all_values:falsetvthen[],to_stringtexpvelseifshow_all_valuesthen(letexp=Magnitude.magnitude_ignoring_minimumvin[`Dim],to_stringtexpv)else[],"";;letto_ci_string~show_all_valuestexp(left,right):Ascii_table_kernel.Attr.tlist*string=let(a1,left),(a2,right)=to_string~show_all_valuestexpleft,to_string~show_all_valuestexprightinifleft=""&&right=""then[],""elsea1@a2,sprintf"%s +%s"leftright;;letto_string_opt~show_all_valuestexp=function|Somev->to_string~show_all_valuestexpv|None->[],"";;