summaryrefslogtreecommitdiff
path: root/lib/python2.7/site-packages/django/bin/profiling
diff options
context:
space:
mode:
authorttt2017-05-13 00:29:47 +0530
committerttt2017-05-13 00:29:47 +0530
commitabf599be33b383a6a5baf9493093b2126a622ac8 (patch)
tree4c5ab6e0d935d5e65fabcf0258e4a00dd20a5afa /lib/python2.7/site-packages/django/bin/profiling
downloadSBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.tar.gz
SBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.tar.bz2
SBHS-2018-Rpi-abf599be33b383a6a5baf9493093b2126a622ac8.zip
added all server files
Diffstat (limited to 'lib/python2.7/site-packages/django/bin/profiling')
-rw-r--r--lib/python2.7/site-packages/django/bin/profiling/__init__.py0
-rw-r--r--lib/python2.7/site-packages/django/bin/profiling/gather_profile_stats.py37
2 files changed, 37 insertions, 0 deletions
diff --git a/lib/python2.7/site-packages/django/bin/profiling/__init__.py b/lib/python2.7/site-packages/django/bin/profiling/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/lib/python2.7/site-packages/django/bin/profiling/__init__.py
diff --git a/lib/python2.7/site-packages/django/bin/profiling/gather_profile_stats.py b/lib/python2.7/site-packages/django/bin/profiling/gather_profile_stats.py
new file mode 100644
index 0000000..0244eb6
--- /dev/null
+++ b/lib/python2.7/site-packages/django/bin/profiling/gather_profile_stats.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+
+"""
+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 os
+import pstats
+import sys
+
+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 path in profiles:
+ 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])