mirror of
https://github.com/littlefs-project/littlefs.git
synced 2025-10-17 07:41:29 +08:00
Added perfbd.py and block device performance sampling in bench-runner
Based loosely on Linux's perf tool, perfbd.py uses trace output with backtraces to aggregate and show the block device usage of all functions in a program, propagating block devices operation cost up the backtrace for each operation. This combined with --trace-period and --trace-freq for sampling/filtering trace events allow the bench-runner to very efficiently record the general cost of block device operations with very little overhead. Adopted this as the default side-effect of make bench, replacing cycle-based performance measurements which are less important for littlefs.
This commit is contained in:
@@ -15,15 +15,12 @@
|
||||
import collections as co
|
||||
import csv
|
||||
import functools as ft
|
||||
import glob
|
||||
import itertools as it
|
||||
import math as m
|
||||
import os
|
||||
import re
|
||||
|
||||
|
||||
CSV_PATHS = ['*.csv']
|
||||
|
||||
# supported merge operations
|
||||
#
|
||||
# this is a terrible way to express these
|
||||
@@ -548,14 +545,14 @@ def table(Result, results, diff_results=None, *,
|
||||
line[-1]))
|
||||
|
||||
|
||||
def openio(path, mode='r'):
|
||||
def openio(path, mode='r', buffering=-1):
|
||||
if path == '-':
|
||||
if mode == 'r':
|
||||
return os.fdopen(os.dup(sys.stdin.fileno()), 'r')
|
||||
return os.fdopen(os.dup(sys.stdin.fileno()), mode, buffering)
|
||||
else:
|
||||
return os.fdopen(os.dup(sys.stdout.fileno()), 'w')
|
||||
return os.fdopen(os.dup(sys.stdout.fileno()), mode, buffering)
|
||||
else:
|
||||
return open(path, mode)
|
||||
return open(path, mode, buffering)
|
||||
|
||||
def main(csv_paths, *,
|
||||
by=None,
|
||||
@@ -605,20 +602,8 @@ def main(csv_paths, *,
|
||||
ops.update(ops_)
|
||||
|
||||
# find CSV files
|
||||
paths = []
|
||||
for path in csv_paths:
|
||||
if os.path.isdir(path):
|
||||
path = path + '/*.csv'
|
||||
|
||||
for path in glob.glob(path):
|
||||
paths.append(path)
|
||||
|
||||
if not paths:
|
||||
print("error: no .csv files found in %r?" % csv_paths)
|
||||
sys.exit(-1)
|
||||
|
||||
results = []
|
||||
for path in paths:
|
||||
for path in csv_paths:
|
||||
try:
|
||||
with openio(path) as f:
|
||||
reader = csv.DictReader(f, restval='')
|
||||
@@ -721,9 +706,7 @@ if __name__ == "__main__":
|
||||
parser.add_argument(
|
||||
'csv_paths',
|
||||
nargs='*',
|
||||
default=CSV_PATHS,
|
||||
help="Description of where to find *.csv files. May be a directory "
|
||||
"or list of paths. Defaults to %r." % CSV_PATHS)
|
||||
help="Input *.csv files.")
|
||||
parser.add_argument(
|
||||
'-q', '--quiet',
|
||||
action='store_true',
|
||||
|
Reference in New Issue
Block a user