git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[StGit PATCH 4/5] Log subprocess calls during performance testing

From
Karl Hasselström <kha@treskal.com>
Date
Jul 17, 2008, 20:42 UTC
Message-ID
<20080717204244.23407.16332.stgit@yoghurt>
In-Reply-To
<20080717204133.23407.34264.stgit@yoghurt>
Log each command's subprocess calls to a separate file.
Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 perf/perftest.py |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/perf/perftest.py b/perf/perftest.py
index 7072772..e5ed04b 100644
--- a/perf/perftest.py
+++ b/perf/perftest.py
@@ -1,4 +1,4 @@
-import datetime, subprocess, sys
+import datetime, os, os.path, subprocess, sys
 
 def duration(t1, t2):
     d = t2 - t1
@@ -8,8 +8,16 @@ class Run(object):
     def __init__(self):
         self.__cwd = None
         self.__log = []
+    def __logfile(self, cmd):
+        fn = os.path.join(os.getcwd(), '%04d.log' % len(self.__log))
+        f = open(fn, 'w')
+        f.write(' '.join(cmd) + '\n' + '-'*70 + '\n\n')
+        f.close()
+        return fn
     def __call__(self, *cmd, **args):
-        kwargs = { 'cwd': self.__cwd }
+        env = dict(os.environ)
+        env['STGIT_SUBPROCESS_LOG'] = 'profile:' + self.__logfile(cmd)
+        kwargs = { 'cwd': self.__cwd, 'env': env }
         if args.get('capture_stdout', False):
             kwargs['stdout'] = subprocess.PIPE
         start = datetime.datetime.now()
Previous: Catalin MarinasNext: Karl Hasselström
Message 7 of 8 in “Performance testing tools”
  1. 0/5 Performance testing toolsKarl Hasselström, Jul 17, 2008
  2. 1/5 Add some performance testing scriptsKarl Hasselström, Jul 17, 2008
  3. 2/5 Log subproces activity to a fileKarl Hasselström, Jul 17, 2008
  4. Catalin MarinasJul 18, 2008
  5. 3/5 Show full command in subprocess profilingKarl Hasselström, Jul 17, 2008
  6. Catalin MarinasJul 18, 2008
  7. 4/5 Log subprocess calls during performance testingKarl Hasselström, Jul 17, 2008
  8. 5/5 Global performance loggingKarl Hasselström, Jul 17, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.