]> granicus.if.org Git - python/commitdiff
Prefer clock() over times() for timer function, except on the Mac,
authorGuido van Rossum <guido@python.org>
Tue, 17 Mar 1998 14:46:43 +0000 (14:46 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 17 Mar 1998 14:46:43 +0000 (14:46 +0000)
where we use GetTicks() -- its clock() is a crock, with only 1 second
accuracy, I believe.

Lib/profile.py

index ae5182ad3dd349e139ca68278fabc66329b282ca..f7de6a42f54db9b46132ce72c9f1a400902e1ad2 100755 (executable)
@@ -149,14 +149,17 @@ class Profile:
                          }
 
                if not timer:
-                       if hasattr(os, 'times'):
-                               self.timer = os.times
-                               self.dispatcher = self.trace_dispatch
-                       elif os.name == 'mac':
+                       if os.name == 'mac':
                                import MacOS
                                self.timer = MacOS.GetTicks
                                self.dispatcher = self.trace_dispatch_mac
                                self.get_time = self.get_time_mac
+                       elif hasattr(time, 'clock'):
+                               self.timer = time.clock
+                               self.dispatcher = self.trace_dispatch_i
+                       elif hasattr(os, 'times'):
+                               self.timer = os.times
+                               self.dispatcher = self.trace_dispatch
                        else:
                                self.timer = time.time
                                self.dispatcher = self.trace_dispatch_i