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
10 import datetime
11 import inspect
15
16 @staticmethod
19
21 self.label = "" if lbl is None else lbl
22 pass
23
25 caller = inspect.stack()[1]
26 self.function = str(caller)
27 self.enter_time = time.clock()
28
30 self.exit_time = time.clock()
31 print("It took " + str(self.exit_time - self.enter_time) +
32 " time units to run through " + self.function + self.label)
33 return False
34
37
39 self.count = 0
40 self.list = []
41
50
52 return str(self.count) + " times, for items [" + str(self.list) + "]"
53
56
59
61 string = ""
62 for key, value in self.metrics.metrics.items():
63 string = string + "metric " + str(key) + ": " + str(value) + "\n"
64 return string
65
68
71
73 string = ""
74 for key, value in self.metrics.metrics.items():
75 string = string + "metric " + \
76 str(key) + " was hit " + str(value.count) + " times\n"
77 return string
78
81
84
87
90
93
101
103 return str(self.verbose)
104
106 total_count = 0
107 metric_count = self[metric].count
108 for key, value in self.metrics.items():
109 total_count = total_count + value.count
110 if total_count > 0:
111 return metric_count / float(total_count)
112 return 0
113