[ARVADOS] created: 372aaff2b572ce772fafc506e9c57d465eb823f6

git at public.curoverse.com git at public.curoverse.com
Fri Jun 19 17:02:08 EDT 2015


        at  372aaff2b572ce772fafc506e9c57d465eb823f6 (commit)


commit 372aaff2b572ce772fafc506e9c57d465eb823f6
Author: radhika <radhika at curoverse.com>
Date:   Fri Jun 19 17:01:32 2015 -0400

    6218: add performance profiling and a sample test in python sdk.

diff --git a/.gitignore b/.gitignore
index eec4758..0871c89 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,3 +16,5 @@ sdk/java/target
 *.class
 sdk/java/log
 /tmp
+sdk/python/tmp
+services/fuse/tmp
diff --git a/sdk/python/tests/performance/__init__.py b/sdk/python/tests/performance/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/sdk/python/tests/performance/performance_profiler.py b/sdk/python/tests/performance/performance_profiler.py
new file mode 100644
index 0000000..3810f92
--- /dev/null
+++ b/sdk/python/tests/performance/performance_profiler.py
@@ -0,0 +1,35 @@
+# Use the PerformanceProfiler class to write your performance tests.
+#
+# Usage:
+#   from performance_profiler import PerformanceProfiler
+#   self.run_profiler(...
+#
+#   See "test_a_sample.py" for a working example.
+#
+# To run performance tests:
+#     cd arvados/sdk/python
+#     python -m unittest discover tests.performance
+#
+#     Alternatively, using run-tests.sh
+#         ./run-tests.sh WORKSPACE=~/arvados --only sdk/python sdk/python_test="--test-suite=tests.performance"
+#
+
+import os
+import unittest
+import sys
+from datetime import datetime
+try:
+    import cProfile as profile
+except ImportError:
+    import profile
+
+class PerformanceProfiler(unittest.TestCase):
+    def run_profiler(self, function, test_name):
+        filename = os.getcwd()+'/tmp/performance/'+ datetime.now().strftime('%Y-%m-%d-%H-%M-%S') +'-' +test_name
+
+        directory = os.path.dirname(filename)
+        if not os.path.exists(directory):
+            os.makedirs(directory)
+
+        sys.stdout = open(filename, 'w')
+        profile.runctx(function, globals(), locals())
diff --git a/sdk/python/tests/performance/test_a_sample.py b/sdk/python/tests/performance/test_a_sample.py
new file mode 100644
index 0000000..cc30ba6
--- /dev/null
+++ b/sdk/python/tests/performance/test_a_sample.py
@@ -0,0 +1,10 @@
+import unittest
+
+from performance_profiler import PerformanceProfiler
+
+class PerformanceTestSample(PerformanceProfiler):
+    def func(self):
+        print 'Hello'
+
+    def test_performance(self):
+        self.run_profiler('self.func', 'test_sample')
diff --git a/services/fuse/tests/performance/__init__.py b/services/fuse/tests/performance/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/services/fuse/tests/performance/performance_profiler.py b/services/fuse/tests/performance/performance_profiler.py
new file mode 120000
index 0000000..1ab8e75
--- /dev/null
+++ b/services/fuse/tests/performance/performance_profiler.py
@@ -0,0 +1 @@
+/home/radhika/arvados/sdk/python/tests/performance/performance_profiler.py
\ No newline at end of file

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list