summaryrefslogtreecommitdiffstats
path: root/google_appengine/lib/django/django/bin/profiling/gather_profile_stats.py
diff options
context:
space:
mode:
Diffstat (limited to 'google_appengine/lib/django/django/bin/profiling/gather_profile_stats.py')
-rwxr-xr-xgoogle_appengine/lib/django/django/bin/profiling/gather_profile_stats.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/google_appengine/lib/django/django/bin/profiling/gather_profile_stats.py b/google_appengine/lib/django/django/bin/profiling/gather_profile_stats.py
new file mode 100755
index 0000000..852f162
--- /dev/null
+++ b/google_appengine/lib/django/django/bin/profiling/gather_profile_stats.py
@@ -0,0 +1,34 @@
+"""
+gather_profile_stats.py /path/to/dir/of/profiles
+
+Note that the aggregated profiles must be read with pstats.Stats, not
+hotshot.stats (the formats are incompatible)
+"""
+
+from hotshot import stats
+import pstats
+import sys, os
+
+def gather_stats(p):
+ profiles = {}
+ for f in os.listdir(p):
+ if f.endswith('.agg.prof'):
+ path = f[:-9]
+ prof = pstats.Stats(os.path.join(p, f))
+ elif f.endswith('.prof'):
+ bits = f.split('.')
+ path = ".".join(bits[:-3])
+ prof = stats.load(os.path.join(p, f))
+ else:
+ continue
+ print "Processing %s" % f
+ if profiles.has_key(path):
+ profiles[path].add(prof)
+ else:
+ profiles[path] = prof
+ os.unlink(os.path.join(p, f))
+ for (path, prof) in profiles.items():
+ prof.dump_stats(os.path.join(p, "%s.agg.prof" % path))
+
+if __name__ == '__main__':
+ gather_stats(sys.argv[1])