summaryrefslogtreecommitdiff
path: root/misc/fontbuild
diff options
context:
space:
mode:
authorRasmus Andersson <rasmus@notion.se>2021-03-25 20:49:12 +0300
committerRasmus Andersson <rasmus@notion.se>2021-03-25 20:49:12 +0300
commit56cba2d659d15129a665a3f540efc85c2b704d12 (patch)
tree0b43ba3af77fd6d69eebd8eebf34d237b10fc924 /misc/fontbuild
parent034e568938497cd398109b191dc2b9e8f5d261e8 (diff)
downloadinter-56cba2d659d15129a665a3f540efc85c2b704d12.tar.xz
tooling: adds a --profile=<file> option to fontbuild for profiling runs and adds misc/tools/fmtprofile.py for printing and inspecting profile results
Diffstat (limited to 'misc/fontbuild')
-rwxr-xr-xmisc/fontbuild22
1 files changed, 21 insertions, 1 deletions
diff --git a/misc/fontbuild b/misc/fontbuild
index 170057d1a..c649fc5e1 100755
--- a/misc/fontbuild
+++ b/misc/fontbuild
@@ -88,6 +88,9 @@ class Main(object):
argparser.add_argument('-q', '--quiet', action='store_true',
help='Only print errors')
+ argparser.add_argument('--profile', metavar='<file>',
+ help='Run in profiler for debugging, writing pstats data to <file>')
+
argparser.add_argument('-C', metavar='<dir>', dest='chdir',
help='Run as if %(prog)s started in <dir> instead of the '+\
'current working directory.')
@@ -126,7 +129,24 @@ class Main(object):
cmd = 'cmd_' + args.command.replace('-', '_')
if not hasattr(self, cmd):
fatal('Unrecognized command %s. Try --help' % args.command)
- getattr(self, cmd)(argv[i:])
+ cmdfn = getattr(self, cmd)
+ if args.profile:
+ try:
+ import cProfile as profile
+ except:
+ import profile
+ import __main__
+ __main__.__dict__["cmdfn"] = cmdfn
+ __main__.__dict__["argv"] = argv[i:]
+ profile.run('cmdfn(argv)', args.profile)
+ print("")
+ print("profile saved to %r. You can now inspect it with for example:" %
+ args.profile)
+ print("misc/tools/fmtprofile.py -n 20 %r" % args.profile)
+ print("python3 -m pstats %r" % args.profile)
+ print("")
+ else:
+ cmdfn(argv[i:])