File tree Expand file tree Collapse file tree 1 file changed +31
-6
lines changed
Expand file tree Collapse file tree 1 file changed +31
-6
lines changed Original file line number Diff line number Diff line change @@ -106,12 +106,20 @@ pub fn bench_add_sample_vs_add2(c: &mut Criterion) {
106106 let functions = dict. functions ( ) ;
107107 let thread_id = get_current_thread_id ( ) ;
108108 let thread_id_key: StringId2 = strings. try_insert ( "thread id" ) . unwrap ( ) . into ( ) ;
109- let labels_api = vec ! [ api:: Label {
110- key: "thread id" ,
111- str : "" ,
112- num: thread_id,
113- num_unit: "" ,
114- } ] ;
109+ let labels_api = vec ! [
110+ api:: Label {
111+ key: "thread id" ,
112+ str : "" ,
113+ num: thread_id,
114+ num_unit: "" ,
115+ } ,
116+ api:: Label {
117+ key: "thread name" ,
118+ str : "this thread" ,
119+ num: 0 ,
120+ num_unit: "" ,
121+ } ,
122+ ] ;
115123
116124 let frames2 = frames. map ( |f| {
117125 let set_id = functions
@@ -128,6 +136,23 @@ pub fn bench_add_sample_vs_add2(c: &mut Criterion) {
128136 } ) ;
129137 let dict = profiling:: profiles:: collections:: Arc :: try_new ( dict) . unwrap ( ) ;
130138
139+ c. bench_function ( "profile_add_sample_timestamped_x1000" , |b| {
140+ b. iter ( || {
141+ let mut profile = profiling:: internal:: Profile :: try_new ( & sample_types, None ) . unwrap ( ) ;
142+ let ( locations, values) = make_stack_api ( frames. as_slice ( ) ) ;
143+ for i in 0 ..1000 {
144+ let sample = api:: Sample {
145+ locations : locations. clone ( ) ,
146+ values : & values,
147+ labels : labels_api. clone ( ) ,
148+ } ;
149+ let ts = std:: num:: NonZeroI64 :: new ( i + 1 ) ;
150+ black_box ( profile. try_add_sample ( sample, ts) ) . unwrap ( ) ;
151+ }
152+ black_box ( profile. only_for_testing_num_aggregated_samples ( ) )
153+ } )
154+ } ) ;
155+
131156 c. bench_function ( "profile_add_sample_frames_x1000" , |b| {
132157 b. iter ( || {
133158 let mut profile = profiling:: internal:: Profile :: try_new ( & sample_types, None ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments