Skip to content

Commit

Permalink
Measure variance across all runs, yielding a single total "range" value
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Mar 4, 2022
1 parent b030f9a commit d157936
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions vmbench.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@
import datetime
import json
import platform
import statistics
import subprocess
import sys
import textwrap
from collections import OrderedDict
from pathlib import Path
from time import time

from cr8.run_crate import run_crate
from cr8.run_spec import run_spec
Expand Down Expand Up @@ -143,9 +145,26 @@ def setup_specs(self):
)

def run_specs(self, count=1):
durations = []
for _ in range(count):
started = int(time() * 1000)
for spec in self.specs:
self.run_spec(spec=spec)
ended = int(time() * 1000)
duration = ended - started
durations.append(duration)

# Compute statistics.
vmin = min(durations)
vmax = max(durations)
vmedian = statistics.median(durations)

# Compute variance.
vrange = (vmax - vmin) / vmedian
vrange = round(vrange, 4)

print()
print(f"Variance: {vrange}")

@staticmethod
def get_specfile(specfile):
Expand Down

0 comments on commit d157936

Please sign in to comment.