1 """
2 Objective-C runtime wrapper for use by LLDB Python formatters
3
4 part of The LLVM Compiler Infrastructure
5 This file is distributed under the University of Illinois Open Source
6 License. See LICENSE.TXT for details.
7 """
8 import lldb
9 import time, datetime
10 import inspect
13 @staticmethod
16
18 self.label = "" if lbl is None else lbl
19 pass
20
22 caller = inspect.stack()[1]
23 self.function = str(caller)
24 self.enter_time = time.clock()
25
27 self.exit_time = time.clock()
28 print "It took " + str(self.exit_time - self.enter_time) + " time units to run through " + self.function + self.label
29 return False
30
33 self.count = 0
34 self.list = []
43 return str(self.count) + " times, for items [" + str(self.list) + "]"
44
49 string = ""
50 for key,value in self.metrics.metrics.items():
51 string = string + "metric " + str(key) + ": " + str(value) + "\n"
52 return string
53
58 string = ""
59 for key,value in self.metrics.metrics.items():
60 string = string + "metric " + str(key) + " was hit " + str(value.count) + " times\n"
61 return string
62
66
69
72
75
83
85 return str(self.verbose)
86
88 total_count = 0
89 metric_count = self[metric].count
90 for key,value in self.metrics.items():
91 total_count = total_count + value.count
92 if total_count > 0:
93 return metric_count / float(total_count)
94 return 0
95