CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
120 lines
3.0 KiB
Python
120 lines
3.0 KiB
Python
"""
|
|
Objective-C runtime wrapper for use by LLDB Python formatters
|
|
|
|
Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
See https://llvm.org/LICENSE.txt for license information.
|
|
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
"""
|
|
import lldb
|
|
import time
|
|
import datetime
|
|
import inspect
|
|
|
|
|
|
class TimeMetrics:
|
|
@staticmethod
|
|
def generate(label=None):
|
|
return TimeMetrics(label)
|
|
|
|
def __init__(self, lbl=None):
|
|
self.label = "" if lbl is None else lbl
|
|
pass
|
|
|
|
def __enter__(self):
|
|
caller = inspect.stack()[1]
|
|
self.function = str(caller)
|
|
self.enter_time = time.clock()
|
|
|
|
def __exit__(self, a, b, c):
|
|
self.exit_time = time.clock()
|
|
print(
|
|
"It took "
|
|
+ str(self.exit_time - self.enter_time)
|
|
+ " time units to run through "
|
|
+ self.function
|
|
+ self.label
|
|
)
|
|
return False
|
|
|
|
|
|
class Counter:
|
|
def __init__(self):
|
|
self.count = 0
|
|
self.list = []
|
|
|
|
def update(self, name):
|
|
self.count = self.count + 1
|
|
# avoid getting the full dump of this ValueObject just to save its
|
|
# metrics
|
|
if isinstance(name, lldb.SBValue):
|
|
self.list.append(name.GetName())
|
|
else:
|
|
self.list.append(str(name))
|
|
|
|
def __str__(self):
|
|
return str(self.count) + " times, for items [" + str(self.list) + "]"
|
|
|
|
|
|
class MetricsPrinter_Verbose:
|
|
def __init__(self, metrics):
|
|
self.metrics = metrics
|
|
|
|
def __str__(self):
|
|
string = ""
|
|
for key, value in self.metrics.metrics.items():
|
|
string = string + "metric " + str(key) + ": " + str(value) + "\n"
|
|
return string
|
|
|
|
|
|
class MetricsPrinter_Compact:
|
|
def __init__(self, metrics):
|
|
self.metrics = metrics
|
|
|
|
def __str__(self):
|
|
string = ""
|
|
for key, value in self.metrics.metrics.items():
|
|
string = (
|
|
string
|
|
+ "metric "
|
|
+ str(key)
|
|
+ " was hit "
|
|
+ str(value.count)
|
|
+ " times\n"
|
|
)
|
|
return string
|
|
|
|
|
|
class Metrics:
|
|
def __init__(self):
|
|
self.metrics = {}
|
|
|
|
def add_metric(self, name):
|
|
self.metrics[name] = Counter()
|
|
|
|
def metric_hit(self, metric, trigger):
|
|
self.metrics[metric].update(trigger)
|
|
|
|
def __getitem__(self, key):
|
|
return self.metrics[key]
|
|
|
|
def __getattr__(self, name):
|
|
if name == "compact":
|
|
return MetricsPrinter_Compact(self)
|
|
if name == "verbose":
|
|
return MetricsPrinter_Verbose(self)
|
|
raise AttributeError(
|
|
"%r object has no attribute %r" % (type(self).__name__, name)
|
|
)
|
|
|
|
def __str__(self):
|
|
return str(self.verbose)
|
|
|
|
def metric_success(self, metric):
|
|
total_count = 0
|
|
metric_count = self[metric].count
|
|
for key, value in self.metrics.items():
|
|
total_count = total_count + value.count
|
|
if total_count > 0:
|
|
return metric_count / float(total_count)
|
|
return 0
|