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

Unified Diff: tools/win/subtract_time.py

Issue 2820843002: Add timeit.bat to tools\win (Closed)
Patch Set: Created 3 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
« no previous file with comments | « no previous file | tools/win/timeit.bat » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/win/subtract_time.py
diff --git a/tools/win/subtract_time.py b/tools/win/subtract_time.py
new file mode 100644
index 0000000000000000000000000000000000000000..4e1559b8d564c19d9542e15413d9fbde9abf93a0
--- /dev/null
+++ b/tools/win/subtract_time.py
@@ -0,0 +1,20 @@
+# Copyright (c) 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+This script converts to %time% compatible strings passed to it into seconds,
+subtracts them, and prints the difference. That's it. It's used by timeit.bat.
+"""
+
+import re
+import sys
+
+def ParseTime(time_string):
+ # Time looks like 15:19:30.32
+ match = re.match("(.*):(.*):(.*)\.(.*)", time_string)
+ hours, minutes, seconds, fraction = map(int, match.groups())
+ return hours * 3600 + minutes * 60 + seconds + fraction * .01
+
+print "%1.2f seconds elapsed time" % (ParseTime(sys.argv[1]) -
+ ParseTime(sys.argv[2]))
« no previous file with comments | « no previous file | tools/win/timeit.bat » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698