Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2547)

Unified Diff: appengine/monorail/framework/test/profiler_test.py

Issue 1868553004: Open Source Monorail (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: appengine/monorail/framework/test/profiler_test.py
diff --git a/appengine/monorail/framework/test/profiler_test.py b/appengine/monorail/framework/test/profiler_test.py
new file mode 100644
index 0000000000000000000000000000000000000000..cd016cdebb0f5f295f48c515284f1687e2f8c56b
--- /dev/null
+++ b/appengine/monorail/framework/test/profiler_test.py
@@ -0,0 +1,48 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is govered by a BSD-style
+# license that can be found in the LICENSE file or at
+# https://developers.google.com/open-source/licenses/bsd
+
+"""Test for monorail.framework.profiler."""
+
+import unittest
+
+from framework import profiler
+
+
+class ProfilerTest(unittest.TestCase):
+
+ def testTopLevelPhase(self):
+ prof = profiler.Profiler()
+ self.assertEquals(prof.current_phase.name, 'overall profile')
+ self.assertEquals(prof.current_phase.parent, None)
+ self.assertEquals(prof.current_phase, prof.top_phase)
+ self.assertEquals(prof.next_color, 0)
+
+ def testSinglePhase(self):
+ prof = profiler.Profiler()
+ self.assertEquals(prof.current_phase.name, 'overall profile')
+ with prof.Phase('test'):
+ self.assertEquals(prof.current_phase.name, 'test')
+ self.assertEquals(prof.current_phase.parent.name, 'overall profile')
+ self.assertEquals(prof.current_phase.name, 'overall profile')
+ self.assertEquals(prof.next_color, 1)
+
+ def testSubphaseExecption(self):
+ prof = profiler.Profiler()
+ try:
+ with prof.Phase('foo'):
+ with prof.Phase('bar'):
+ pass
+ with prof.Phase('baz'):
+ raise Exception('whoops')
+ except Exception as e:
+ self.assertEquals(e.message, 'whoops')
+ finally:
+ self.assertEquals(prof.current_phase.name, 'overall profile')
+ self.assertEquals(
+ prof.top_phase.subphases[0].subphases[1].name, 'baz')
+
+
+if __name__ == '__main__':
+ unittest.main()
« no previous file with comments | « appengine/monorail/framework/test/permissions_test.py ('k') | appengine/monorail/framework/test/ratelimiter_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698