diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2019-03-05 14:27:35 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2019-03-05 14:27:35 +0100 |
| commit | 043598070d4cb62facfedf59a87adb9e2a3cb7da (patch) | |
| tree | 509876954e31be678b3a687af6317765dd002a3b /src/benchmark.py | |
| parent | 12922d12c20a9a80f191b37e5571c7563e993ddc (diff) | |
| download | allocbench-043598070d4cb62facfedf59a87adb9e2a3cb7da.tar.gz allocbench-043598070d4cb62facfedf59a87adb9e2a3cb7da.zip | |
add function to scale thread to available cpus
Diffstat (limited to 'src/benchmark.py')
| -rw-r--r-- | src/benchmark.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/benchmark.py b/src/benchmark.py index e5620ae..18934f7 100644 --- a/src/benchmark.py +++ b/src/benchmark.py @@ -2,6 +2,7 @@ from collections import namedtuple import csv import itertools import matplotlib.pyplot as plt +import multiprocessing import numpy as np import os import pickle @@ -27,6 +28,26 @@ class Benchmark (object): "allocators": allocators, } + @staticmethod + def scale_threads_for_cpus(factor): + cpus = multiprocessing.cpu_count() + max_threads = cpus * factor + steps = 1 + if max_threads > 40: + steps = 2 + if max_threads > 100: + steps = 5 + if max_threads > 200: + steps = 10 + + # Special thread counts + nthreads = set([1, cpus/2, cpus, cpus*factor]) + nthreads.update(range(steps, cpus * factor + 1, steps)) + nthreads = list(nthreads) + nthreads.sort() + + return nthreads + def __init__(self): # Set default values for k in Benchmark.defaults: @@ -48,6 +69,12 @@ class Benchmark (object): if not hasattr(self, "requirements"): self.requirements = [] + print_debug("Creating benchmark", self.name) + print_debug("Cmd:", self.cmd) + print_debug("Args:", self.args) + print_debug("Requirements:", self.requirements) + print_debug("Results dictionary:", self.results) + def save(self, path=None): f = path if path else self.name + ".save" print_info("Saving results to:", self.name + ".save") |
