Ejemplo n.º 1
0
try:
    os.remove(filename)
except:
    pass

logging.basicConfig(level=logging.DEBUG, filename=filename)

# get rustc sha

sha = rustc["--version"]().split(" (")[1].split(" ")[0]

logging.debug("rust sha: %r" % sha)

# do overhead adjustment (assume that 1 second is enough to accurately gague
# overhead, and that sleep 1 actually sleeps for 1 second)
overhead = avg([x.elapsed - 1 for x in (measure_cmd(sleep['1']),
                measure_cmd(sleep['1']), measure_cmd(sleep['1']))])

logging.debug("overhead: %r" % overhead)

if "#[bench]" in open(crate).read():
    benchrunner = True
else:
    benchrunner = False

if benchrunner:
    rustcc = rustc["--test"]
else:
    rustcc = rustc

rustcc = rustcc["-Z", "time-passes", "-O", "-o", binname, crate]
Ejemplo n.º 2
0
from plumbum.cmd import rustc, sleep, sudo, cgcreate

from benchlib import measure_cmd, process_stat


def avg(l):
    return sum(l) / len(l)

cmd = sys.argv[1:]

user = os.environ['USER']

filename = os.getenv('MEMBENCH_LOGFILE', 'membench.log')
try:
    os.remove(filename)
except:
    pass

logging.basicConfig(level=logging.DEBUG, filename=filename)

cmd = local[cmd[0]][tuple(cmd[1:])]

outp = measure_cmd(cmd)

data = dict(outp.__dict__)
data["cli"] = str(cmd)
data["memory_data"] = process_stat(outp.memory_data)
data["cpuacct"] = dict(outp.cpuacct.__dict__)

sys.stdout.write(json.dumps(data) + "\n")