forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBenchmark_GuardMalloc.in
66 lines (50 loc) · 2.03 KB
/
Benchmark_GuardMalloc.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# ===--- Benchmark_GuardMalloc.in ----------------------------------------===//
#
# This source file is part of the Swift.org open source project
#
# Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
# Licensed under Apache License v2.0 with Runtime Library Exception
#
# See https://swift.org/LICENSE.txt for license information
# See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
#
# ===---------------------------------------------------------------------===//
import os
import subprocess
import sys
sys.path.append("@PATH_TO_DRIVER_LIBRARY@")
import perf_test_driver # noqa (E402 module level import not at top of file)
# Regexes for the XFAIL_LIST. Matches against '([Onone|O|Osize],TestName)'
XFAIL_LIST = []
class GuardMallocResult(perf_test_driver.Result):
def __init__(self, name, status):
perf_test_driver.Result.__init__(self, name, status, "", XFAIL_LIST)
class GuardMallocBenchmarkDriver(perf_test_driver.BenchmarkDriver):
def __init__(self, binary, xfail_list):
perf_test_driver.BenchmarkDriver.__init__(
self, binary, xfail_list, enable_parallel=True
)
self.new_env = os.environ.copy()
self.new_env["DYLD_INSERT_LIBRARIES"] = "/usr/lib/libgmalloc.dylib"
def prepare_input(self, name):
return {"env": self.new_env}
def process_input(self, data):
test_name = "({},{})".format(data["opt"], data["test_name"])
print("Running {}...".format(test_name))
sys.stdout.flush()
p = subprocess.Popen(
[data["path"], data["test_name"], "--num-iters=2"],
env=data["env"],
stderr=open("/dev/null", "w"),
stdout=open("/dev/null", "w"),
)
status = p.wait()
return GuardMallocResult(test_name, status)
SWIFT_BIN_DIR = os.path.dirname(os.path.abspath(__file__))
if __name__ == "__main__":
g = GuardMallocBenchmarkDriver(SWIFT_BIN_DIR, XFAIL_LIST)
if g.run():
sys.exit(0)
else:
sys.exit(-1)