moved Singleton class to a better place

work related to [https://bugzilla.ipr.univ-rennes.fr/show_bug.cgi?id=3958]
This commit is contained in:
Guillaume Raffy 2024-10-23 10:55:37 +02:00
parent 6f84732cf6
commit fe4d66fb52
3 changed files with 11 additions and 10 deletions

View File

@ -9,15 +9,6 @@ BenchParamType = Union[int, str]
BenchmarkConfig = Dict[BenchParamId, BenchParamType]
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(type(cls), cls).__call__(*args, **kwargs) # pylint: disable=bad-super-call, no-member
return cls._instances[cls]
class BenchParam():
'''a parameter of a benchmark

View File

@ -1,6 +1,7 @@
from .core import BenchmarkId, IBenchmark, Singleton
from .core import BenchmarkId, IBenchmark
from .benchmarks.hibench import HiBench
from .benchmarks.mamul1 import MaMul1
from .util import Singleton
import logging
import argparse
from pathlib import Path

View File

@ -5,6 +5,15 @@ import shutil
import logging
class Singleton(type):
_instances = {}
def __call__(cls, *args, **kwargs):
if cls not in cls._instances:
cls._instances[cls] = super(type(cls), cls).__call__(*args, **kwargs) # pylint: disable=bad-super-call, no-member
return cls._instances[cls]
def _extract_res_dir_using_py_3_7(dir_resource_package: str, dest_path: Path):
dest_path.mkdir(parents=True, exist_ok=True)
dir_contents = importlib.resources.contents(dir_resource_package)