Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file filter.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128openCoreopenPolyopenCore_profileropenCore_profiler_disabledtype-'rwt={(* This table maps raw interests (from the event generator) to
(the filter we want to check, the original interest). *)interests:(Probe_id.tInterest.tlist)Interest.Raw.I.Table.t;id_map:Reader.Header.t}letcreate(id_map:Reader.Header.t)={interests=Interest.Raw.I.Table.create();id_map}letadd_interesttinterest=(* Check that value/delta filters are only applied to probes,
and that the units on all filters are correct. *)beginmatchinterestwith|Interest.All_->()|Interest.In_interval(_,Time_delta,iv_units,_)->ifiv_units<>Profiler_units.Nanosecondsthenfailwith"Units of time delta interval should be nanoseconds"|Interest.In_interval(_,(Value|Delta),iv_units,_)->letunits=Interest.specinterestt.id_map|>Probe_type.units|>Option.value_exn~message:"Can't test the value / delta of a timer"inifunits<>iv_unitsthenfailwith"Units of interval do not match units of Probe"end;(* Check that delta / time_delta filters are only applied to paths *)beginmatchinterestwith|Interest.All_->()|Interest.In_interval(Group_path_,(Delta|Time_delta),_,_)->()|Interest.In_interval(_,Value,_,_)->()|Interest.In_interval((Group_point_|Single_),(Delta|Time_delta),_,_)->failwith"Can only filter time deltas / deltas when considering a path"end;Hashtbl.add_multit.interests~key:(Interest.rawinterest)~data:interest;;letread_only(t:_t)=(t:>readt)(* [add_interest] asserts that we only filter on legal subjects, so
we can safely pass junk values in delta and time_delta when appropriate,
and it won't match a case that uses them *)lettest_one~value~time_delta~deltainterest=match(interest:'aInterest.t)with|All_->true|In_interval(_,sub,_,interval)->letsub'=matchsubwith|Value->value|Time_delta->Time_ns.Span.to_int_nstime_delta|Delta->deltainInterval.Int.containsintervalsub'lettesttevent=match(event:Event_generator.event)with|Timer(interest,_t)->Hashtbl.findt.interestsinterest(* Since the only interests that can be registered for Timers are [All]... *)|>Option.value~default:[]|Probe(interest,_t,value)->Hashtbl.findt.interestsinterest|>Option.value~default:[]|>List.filter~f:(test_one~value~time_delta:Time_ns.Span.zero~delta:0)|Timer_path{interest;time_delta;time=_}->Hashtbl.findt.interestsinterest|>Option.value~default:[]|>List.filter~f:(test_one~value:0~time_delta~delta:0)|Probe_path{interest;time_delta;delta;value;time=_}->Hashtbl.findt.interestsinterest|>Option.value~default:[]|>List.filter~f:(test_one~value~time_delta~delta)(* = not (List.is_empty (test t event)) *)lettest'tevent=match(event:Event_generator.event)with|Timer(interest,_t)->beginmatchHashtbl.findt.interestsinterestwith|None|Some[]->false|Some(_::_)->trueend|Probe(interest,_t,value)->Hashtbl.findt.interestsinterest|>Option.value~default:[]|>List.exists~f:(test_one~value~time_delta:Time_ns.Span.zero~delta:0)|Timer_path{interest;time_delta;time=_}->Hashtbl.findt.interestsinterest|>Option.value~default:[]|>List.exists~f:(test_one~value:0~time_delta~delta:0)|Probe_path{interest;time_delta;delta;value;time=_}->Hashtbl.findt.interestsinterest|>Option.value~default:[]|>List.exists~f:(test_one~value~time_delta~delta)letiter_eventstevents~f=Event_generator.iter_eventsevents~f:(funevent->matchtestteventwith|[]->()|(_::_)asinterests->feventinterests)letiter_events_intereststevents~f=Event_generator.iter_eventsevents~f:(funevent->List.iter(testtevent)~f:(fevent))letraw_interestst=Hashtbl.keyst.interests