Skip to content

Commit

Permalink
bencher corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
deepinthebuild committed Feb 16, 2018
1 parent dfeee39 commit e822c86
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions benchsuite/benchrunner
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ CORPUS_UNPACK_DIR = os.path.join("Europarl", "raw", "en")
CORPUS_URL = "opus.nlpl.eu/download.php?f=Europarl/en.raw.tar.gz"

class Benchmarker():
def __init__(self, name, warmup=1, count=5, commands=None):
def __init__(self, name, warmup=1, count=3, commands=None):
self.name = name
self.warmup = warmup
self.count = count
self.commands = commands or []

def run(self)
def run(self):
test_dir = os.path.join(os.getcwd(), TEST_DIR)
times = []
for _ in range(self.warmup):
subprocess.run(commands, cwd=test_dir, stdout=subprocess.DEVNULL, shell=True)
subprocess.run(self.commands, cwd=test_dir, stdout=subprocess.DEVNULL, shell=True)

for _ in range(self.count):
start = time.time()
subprocess.run(commands, cwd=test_dir, stdout=subprocess.DEVNULL, shell=True)
subprocess.run(self.commands, cwd=test_dir, stdout=subprocess.DEVNULL, shell=True)
end = time.time()
times.push(end - start)
times.append(end - start)

return times

Expand Down Expand Up @@ -61,7 +61,7 @@ def download_and_pack_corpus():


def main():
p = argparse.ArgumentParse("Command line deduplication tool benchmark runner.")
p = argparse.ArgumentParser("Command line deduplication tool benchmark runner.")
p.add_argument(
'--warmup', metavar='INTEGER', type=int, default=1,
help='The number of iterations to run each command before '
Expand All @@ -78,8 +78,8 @@ def main():
gnu_results = gnu_coreutils.run()
dedup_results = cjm_dedup.run()

print("sort | uniq: {} mean: {}", gnu_results, statistics.mean(gnu_results))
print("dedup: {} mean: {}", dedup_results, statistics.mean(dedup_results))
print("sort | uniq: {} mean: {}".format(gnu_results, statistics.mean(gnu_results)))
print("dedup: {} mean: {}".format(dedup_results, statistics.mean(dedup_results)))


if __name__ == '__main__':
Expand Down

0 comments on commit e822c86

Please sign in to comment.