@@ -345,13 +345,13 @@ const reasonable_defaults =
345
345
[EventType(:cache, :L1_data, :write, :access),
346
346
EventType(:cache, :L1_data, :write, :miss)]=# ]
347
347
348
- function make_bench (x)
348
+ function make_bench (x; kwargs ... )
349
349
groups = EventGroup[]
350
350
for y in x
351
351
if isa (y, EventType)
352
- push! (groups, EventGroup ([y]))
352
+ push! (groups, EventGroup ([y]; kwargs ... ))
353
353
else
354
- push! (groups, EventGroup (y))
354
+ push! (groups, EventGroup (y; kwargs ... ))
355
355
end
356
356
end
357
357
PerfBench (groups)
@@ -443,17 +443,22 @@ function parse_pstats_options(opts)
443
443
(instructions, branch-instructions, branch-misses),
444
444
(task-clock, context-switches, cpu-migrations, page-faults)
445
445
" )
446
+ exclude_kernel = false
446
447
for opt in opts
447
448
if opt isa AbstractString
448
449
events = parse_groups (opt)
449
450
elseif opt isa Expr && opt. head == :(= )
450
451
key, val = opt. args
451
- error (" unknown key: $(key) " )
452
+ if key === :exclude_kernel
453
+ exclude_kernel = esc (val)
454
+ else
455
+ error (" unknown key: $(key) " )
456
+ end
452
457
else
453
458
error (" unknown option: $(opt) " )
454
459
end
455
460
end
456
- return (events = events,)
461
+ return (events = events, exclude_kernel = exclude_kernel, )
457
462
end
458
463
459
464
# syntax: groups = (group ',')* group
@@ -661,7 +666,8 @@ may follow these columns after a hash (#) character.
661
666
662
667
The macro can take some options. If a string object is passed, it is a
663
668
comma-separated list of event names to measure. An event group can be
664
- indicated by a pair of parentheses.
669
+ indicated by a pair of parentheses. If `exclude_kernel = true` is passed, the
670
+ count excludes events that happen in kernel space (`false` by default).
665
671
666
672
# Examples
667
673
@@ -701,7 +707,7 @@ macro pstats(args...)
701
707
opts, expr = parse_pstats_options (args[1 : end - 1 ]), args[end ]
702
708
quote
703
709
(function ()
704
- bench = make_bench ($ (opts. events))
710
+ bench = make_bench ($ (opts. events), userspace_only = $ (opts . exclude_kernel) )
705
711
enable! (bench)
706
712
val = $ (esc (expr))
707
713
disable! (bench)
0 commit comments