#!/usr/bin/python import subprocess import random import math def kernel_scale (rtime, total, stime): p = subprocess.Popen("./scale_stime " + str(rtime) + " " + str(total) + " " + str(stime) , shell=True, stdout=subprocess.PIPE) return int(p.stdout.read()) def python_scale (rtime, total, stime): return (stime * rtime) / total max_rtime = 364*24*60*60*1000 # 1 year (on one thread) fail=False for i in range(0, 100): rtime = random.randrange(max_rtime) total = int(random.uniform(0.7, 1.3) * rtime) for n in range(1, 11): stime = (n * total / 10) r1 = kernel_scale(rtime, total, stime) r2 = python_scale(rtime, total, stime) if abs(r1 - r2) > 1: print "FAIL!" print "rtime: " + str(rtime) print "total: " + str(total) print "stime: " + str(stime) print "kernel: " + str(r1) print "python: " + str(r2) fail=True break if fail: break;