Skip to content

Instantly share code, notes, and snippets.

@jbosboom
Created September 17, 2025 08:57
Show Gist options
  • Select an option

  • Save jbosboom/71a46d5c2768479e38f44f653b6033ce to your computer and use it in GitHub Desktop.

Select an option

Save jbosboom/71a46d5c2768479e38f44f653b6033ce to your computer and use it in GitHub Desktop.
Microbenchmarks for os.stat using statx
(venv) [jbosboom@promenade build-main]$ python -m pyperf timeit --rigorous --hist --stats --affinity 0 -s 'import os' 'os.stat(".")'
.........................................
1.89 us: 1 ####
1.89 us: 2 ########
1.90 us: 0 |
1.90 us: 0 |
1.90 us: 2 ########
1.91 us: 5 ####################
1.91 us: 4 ################
1.92 us: 11 ###########################################
1.92 us: 13 ###################################################
1.93 us: 17 ###################################################################
1.93 us: 17 ###################################################################
1.93 us: 12 ###############################################
1.94 us: 9 ###################################
1.94 us: 4 ################
1.95 us: 7 ############################
1.95 us: 4 ################
1.95 us: 7 ############################
1.96 us: 2 ########
1.96 us: 1 ####
1.97 us: 1 ####
1.97 us: 1 ####
Total duration: 21.6 sec
Start date: 2025-09-17 01:17:45
End date: 2025-09-17 01:18:10
Raw value minimum: 124 ms
Raw value maximum: 129 ms
Number of calibration run: 1
Number of run with values: 40
Total number of run: 41
Number of warmup per run: 1
Number of value per run: 3
Loop iterations per value: 2^16
Total number of values: 120
Minimum: 1.89 us
Median +- MAD: 1.93 us +- 0.01 us
Mean +- std dev: 1.93 us +- 0.01 us
Maximum: 1.97 us
0th percentile: 1.89 us (-2% of the mean) -- minimum
5th percentile: 1.91 us (-1% of the mean)
25th percentile: 1.92 us (-0% of the mean) -- Q1
50th percentile: 1.93 us (-0% of the mean) -- median
75th percentile: 1.94 us (+0% of the mean) -- Q3
95th percentile: 1.96 us (+1% of the mean)
100th percentile: 1.97 us (+2% of the mean) -- maximum
Number of outlier (out of 1.90 us..1.97 us): 5
Mean +- std dev: 1.93 us +- 0.01 us
(venv) [jbosboom@promenade build-main]$ enosys -s statx python -m pyperf timeit --rigorous --hist --stats --affinity 0 -s 'import os' 'os.stat(".")'
.........................................
1.55 us: 1 #
1.58 us: 0 |
1.60 us: 0 |
1.62 us: 0 |
1.65 us: 0 |
1.67 us: 0 |
1.70 us: 0 |
1.72 us: 0 |
1.74 us: 0 |
1.77 us: 0 |
1.79 us: 0 |
1.81 us: 0 |
1.84 us: 0 |
1.86 us: 0 |
1.89 us: 0 |
1.91 us: 0 |
1.93 us: 3 ###
1.96 us: 5 #####
1.98 us: 36 ######################################
2.01 us: 63 ###################################################################
2.03 us: 12 #############
Total duration: 22.3 sec
Start date: 2025-09-17 01:20:59
End date: 2025-09-17 01:21:25
Raw value minimum: 103 ms
Raw value maximum: 134 ms
Number of calibration run: 1
Number of run with values: 40
Total number of run: 41
Number of warmup per run: 1
Number of value per run: 3
Loop iterations per value: 2^16
Total number of values: 120
Minimum: 1.57 us
Median +- MAD: 2.01 us +- 0.01 us
Mean +- std dev: 2.01 us +- 0.04 us
Maximum: 2.05 us
0th percentile: 1.57 us (-22% of the mean) -- minimum
5th percentile: 1.97 us (-2% of the mean)
25th percentile: 2.00 us (-0% of the mean) -- Q1
50th percentile: 2.01 us (+0% of the mean) -- median
75th percentile: 2.02 us (+1% of the mean) -- Q3
95th percentile: 2.03 us (+1% of the mean)
100th percentile: 2.05 us (+2% of the mean) -- maximum
Number of outlier (out of 1.97 us..2.05 us): 8
Mean +- std dev: 2.01 us +- 0.04 us
(venv) [jbosboom@promenade build-statx-nostatbtime]$ python -m pyperf timeit --rigorous --hist --stats --affinity 0 -s 'import os' 'os.stat(".")'
.........................................
1.90 us: 1 ###
1.90 us: 2 #######
1.90 us: 1 ###
1.91 us: 1 ###
1.91 us: 0 |
1.92 us: 1 ###
1.92 us: 2 #######
1.92 us: 1 ###
1.93 us: 3 ##########
1.93 us: 12 ########################################
1.93 us: 20 ###################################################################
1.94 us: 14 ###############################################
1.94 us: 19 ################################################################
1.95 us: 12 ########################################
1.95 us: 8 ###########################
1.95 us: 6 ####################
1.96 us: 2 #######
1.96 us: 4 #############
1.97 us: 5 #################
1.97 us: 2 #######
1.97 us: 4 #############
Total duration: 21.7 sec
Start date: 2025-09-17 01:18:29
End date: 2025-09-17 01:18:54
Raw value minimum: 124 ms
Raw value maximum: 130 ms
Number of calibration run: 1
Number of run with values: 40
Total number of run: 41
Number of warmup per run: 1
Number of value per run: 3
Loop iterations per value: 2^16
Total number of values: 120
Minimum: 1.90 us
Median +- MAD: 1.94 us +- 0.01 us
Mean +- std dev: 1.94 us +- 0.01 us
Maximum: 1.98 us
0th percentile: 1.90 us (-2% of the mean) -- minimum
5th percentile: 1.92 us (-1% of the mean)
25th percentile: 1.94 us (-0% of the mean) -- Q1
50th percentile: 1.94 us (-0% of the mean) -- median
75th percentile: 1.95 us (+0% of the mean) -- Q3
95th percentile: 1.97 us (+1% of the mean)
100th percentile: 1.98 us (+2% of the mean) -- maximum
Number of outlier (out of 1.91 us..1.97 us): 9
Mean +- std dev: 1.94 us +- 0.01 us
(venv) [jbosboom@promenade build-statx-nostatbtime]$ enosys -s statx python -m pyperf timeit --rigorous --hist --stats --affinity 0 -s 'import os' 'os.stat(".")'
.........................................
1.90 us: 1 ##
1.91 us: 1 ##
1.92 us: 0 |
1.93 us: 1 ##
1.94 us: 0 |
1.94 us: 0 |
1.95 us: 0 |
1.96 us: 0 |
1.97 us: 0 |
1.98 us: 0 |
1.99 us: 0 |
2.00 us: 0 |
2.01 us: 1 ##
2.02 us: 15 ##########################
2.03 us: 38 ###################################################################
2.04 us: 27 ################################################
2.05 us: 21 #####################################
2.06 us: 9 ################
2.07 us: 2 ####
2.07 us: 2 ####
2.08 us: 2 ####
Total duration: 22.7 sec
Start date: 2025-09-17 01:22:24
End date: 2025-09-17 01:22:50
Raw value minimum: 125 ms
Raw value maximum: 137 ms
Number of calibration run: 1
Number of run with values: 40
Total number of run: 41
Number of warmup per run: 1
Number of value per run: 3
Loop iterations per value: 2^16
Total number of values: 120
Minimum: 1.90 us
Median +- MAD: 2.04 us +- 0.01 us
Mean +- std dev: 2.04 us +- 0.02 us
Maximum: 2.09 us
0th percentile: 1.90 us (-7% of the mean) -- minimum
5th percentile: 2.02 us (-1% of the mean)
25th percentile: 2.03 us (-0% of the mean) -- Q1
50th percentile: 2.04 us (+0% of the mean) -- median
75th percentile: 2.05 us (+0% of the mean) -- Q3
95th percentile: 2.06 us (+1% of the mean)
100th percentile: 2.09 us (+2% of the mean) -- maximum
Number of outlier (out of 2.00 us..2.07 us): 7
Mean +- std dev: 2.04 us +- 0.02 us
(venv) [jbosboom@promenade build]$ python -m pyperf timeit --rigorous --hist --stats --affinity 0 -s 'import os' 'os.stat(".")'
.........................................
1.92 us: 1 ####
1.92 us: 1 ####
1.93 us: 1 ####
1.93 us: 1 ####
1.93 us: 0 |
1.94 us: 0 |
1.94 us: 1 ####
1.95 us: 0 |
1.95 us: 4 ################
1.96 us: 10 #######################################
1.96 us: 16 ###############################################################
1.96 us: 15 ###########################################################
1.97 us: 15 ###########################################################
1.97 us: 17 ###################################################################
1.98 us: 17 ###################################################################
1.98 us: 9 ###################################
1.99 us: 8 ################################
1.99 us: 1 ####
2.00 us: 0 |
2.00 us: 1 ####
2.00 us: 2 ########
Total duration: 22.1 sec
Start date: 2025-09-17 01:23:35
End date: 2025-09-17 01:24:01
Raw value minimum: 126 ms
Raw value maximum: 132 ms
Number of calibration run: 1
Number of run with values: 40
Total number of run: 41
Number of warmup per run: 1
Number of value per run: 3
Loop iterations per value: 2^16
Total number of values: 120
Minimum: 1.92 us
Median +- MAD: 1.97 us +- 0.01 us
Mean +- std dev: 1.97 us +- 0.01 us
Maximum: 2.01 us
0th percentile: 1.92 us (-3% of the mean) -- minimum
5th percentile: 1.96 us (-1% of the mean)
25th percentile: 1.96 us (-0% of the mean) -- Q1
50th percentile: 1.97 us (+0% of the mean) -- median
75th percentile: 1.98 us (+0% of the mean) -- Q3
95th percentile: 1.99 us (+1% of the mean)
100th percentile: 2.01 us (+2% of the mean) -- maximum
Number of outlier (out of 1.94 us..2.01 us): 6
Mean +- std dev: 1.97 us +- 0.01 us
(venv) [jbosboom@promenade build]$ enosys -s statx python -m pyperf timeit --rigorous --hist --stats --affinity 0 -s 'import os' 'os.stat(".")'
.........................................
1.93 us: 1 ##
1.93 us: 0 |
1.94 us: 0 |
1.95 us: 0 |
1.96 us: 0 |
1.97 us: 0 |
1.98 us: 1 ##
1.98 us: 0 |
1.99 us: 0 |
2.00 us: 8 #################
2.01 us: 13 ###########################
2.02 us: 32 ###################################################################
2.03 us: 29 #############################################################
2.04 us: 22 ##############################################
2.04 us: 8 #################
2.05 us: 2 ####
2.06 us: 0 |
2.07 us: 0 |
2.08 us: 2 ####
2.09 us: 1 ##
2.09 us: 1 ##
Total duration: 22.7 sec
Start date: 2025-09-17 01:24:35
End date: 2025-09-17 01:25:01
Raw value minimum: 126 ms
Raw value maximum: 138 ms
Number of calibration run: 1
Number of run with values: 40
Total number of run: 41
Number of warmup per run: 1
Number of value per run: 3
Loop iterations per value: 2^16
Total number of values: 120
Minimum: 1.93 us
Median +- MAD: 2.03 us +- 0.01 us
Mean +- std dev: 2.03 us +- 0.02 us
Maximum: 2.10 us
0th percentile: 1.93 us (-5% of the mean) -- minimum
5th percentile: 2.01 us (-1% of the mean)
25th percentile: 2.02 us (-0% of the mean) -- Q1
50th percentile: 2.03 us (-0% of the mean) -- median
75th percentile: 2.04 us (+0% of the mean) -- Q3
95th percentile: 2.05 us (+1% of the mean)
100th percentile: 2.10 us (+3% of the mean) -- maximum
Number of outlier (out of 1.99 us..2.06 us): 6
Mean +- std dev: 2.03 us +- 0.02 us
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment