Last active
May 16, 2018 14:15
-
-
Save ricarkol/0cef066f51fa018c77ac5b1486f19c1f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import pexpect | |
import os | |
import time | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--cmd', dest='cmd', help='unikernel command', default='echo hi', type=str) | |
parser.add_argument('--show', dest='show', help='show output', default=False, type=bool) | |
parser.add_argument('--num', dest='num', help='number of runs', default=10, type=int) | |
parser.add_argument('--timeout', dest='timeout', help='timeout', default=30, type=int) | |
args = parser.parse_args() | |
for i in range(0, args.num): | |
t0 = time.time() | |
vm = pexpect.spawn(args.cmd, timeout=args.timeout) | |
try: | |
vm.expect('Running') | |
t1 = time.time() | |
print(t1 - t0) | |
finally: | |
vm.close() | |
if args.show: | |
print vm.before |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment