mirror of
https://github.com/LTTLabsOSS/markbench-tests.git
synced 2026-01-09 14:07:56 -05:00
Add primesieve
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,6 +11,7 @@ run/
|
||||
benchmark-launcher-cli-3.1.0-windows.zip
|
||||
flac-1.4.3-win/
|
||||
flac-1.4.3-win.zip
|
||||
primesieve-12.3*
|
||||
y-cruncher v0.8.2.9522/
|
||||
y-cruncher v0.8.2.9522.zip
|
||||
basegame_no_intro_videos.archive
|
||||
|
||||
@@ -10,6 +10,7 @@ Links to licenses and repositories of dependencies used throughout MarkBench tes
|
||||
| Blender Benchmark | [Blender Benchmark](https://opendata.blender.org/) | [GNU GPL](https://www.blender.org/about/license/) |
|
||||
| FLAC Audio Encode | [FLAC](https://xiph.org/flac/index.html) | [BSD](https://xiph.org/flac/license.html) |
|
||||
| y-cruncher | [y-cruncher](http://www.numberworld.org/y-cruncher/) | [Unique](http://www.numberworld.org/y-cruncher/license.html) |
|
||||
| primesieve | [primesieve](https://github.com/kimwalisch/primesieve?tab=BSD-2-Clause-1-ov-file#readme) | [BSD-2](https://github.com/kimwalisch/primesieve?tab=BSD-2-Clause-1-ov-file#readme) |
|
||||
|
||||
## Required files
|
||||
|
||||
|
||||
13
primesieve/README.md
Normal file
13
primesieve/README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
# Primesieve
|
||||
|
||||
Wrapper for [primesieve](https://github.com/kimwalisch/primesieve) which calculates primenumbers and measures duration.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Python 3.10+
|
||||
|
||||
## Output
|
||||
|
||||
report.json
|
||||
- `score`: the average duration in seconds
|
||||
- `version`: the version of primesieve
|
||||
5
primesieve/manifest.yaml
Normal file
5
primesieve/manifest.yaml
Normal file
@@ -0,0 +1,5 @@
|
||||
friendly_name: "Primesieve"
|
||||
executable: "primesieve.py"
|
||||
process_name: "primesieve.exe"
|
||||
disable_presentmon: true
|
||||
output_dir: "run"
|
||||
61
primesieve/primesieve.py
Normal file
61
primesieve/primesieve.py
Normal file
@@ -0,0 +1,61 @@
|
||||
"""Test script for primesieve"""
|
||||
import json
|
||||
import logging
|
||||
import os.path
|
||||
import subprocess
|
||||
import sys
|
||||
import re
|
||||
|
||||
sys.path.insert(1, os.path.join(sys.path[0], ".."))
|
||||
|
||||
from primesieve_utils import PRIMESIEVE_FOLDER_NAME, current_time_ms, download_primesieve, primesieve_folder_exists
|
||||
|
||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
log_dir = os.path.join(script_dir, "run")
|
||||
if not os.path.isdir(log_dir):
|
||||
os.mkdir(log_dir)
|
||||
LOGGING_FORMAT = '%(asctime)s %(levelname)-s %(message)s'
|
||||
logging.basicConfig(filename=f'{log_dir}/harness.log',
|
||||
format=LOGGING_FORMAT,
|
||||
datefmt='%m-%d %H:%M',
|
||||
level=logging.DEBUG)
|
||||
console = logging.StreamHandler()
|
||||
formatter = logging.Formatter(LOGGING_FORMAT)
|
||||
console.setFormatter(formatter)
|
||||
logging.getLogger('').addHandler(console)
|
||||
|
||||
if primesieve_folder_exists() is False:
|
||||
logging.info("Downloading primesieve")
|
||||
download_primesieve()
|
||||
|
||||
ABS_EXECUTABLE_PATH = os.path.join(script_dir, PRIMESIEVE_FOLDER_NAME, "primesieve.exe")
|
||||
|
||||
# omit the first arg which is the script name
|
||||
command = f'{ABS_EXECUTABLE_PATH}'
|
||||
command = command.rstrip()
|
||||
scores = []
|
||||
start_time = current_time_ms()
|
||||
for i in range(3):
|
||||
output = subprocess.check_output([command, "1e12", "--quiet", "--time"], text=True)
|
||||
SCORE_PATTERN = r'Seconds:\s(\d+\.\d+)'
|
||||
if "Seconds" in output:
|
||||
duration = re.match(SCORE_PATTERN, output).group(1)
|
||||
scores.append(float(duration))
|
||||
end_time = current_time_ms()
|
||||
|
||||
SCORE_SUM = 0
|
||||
for score in scores:
|
||||
SCORE_SUM += score
|
||||
avg_score = round(SCORE_SUM / len(scores), 2)
|
||||
|
||||
report = {
|
||||
"start_time": start_time,
|
||||
"version": "12.3",
|
||||
"end_time": end_time,
|
||||
"score": avg_score,
|
||||
"unit": "seconds",
|
||||
"test": "Primesieve 1e12"
|
||||
}
|
||||
|
||||
with open(os.path.join(log_dir, "report.json"), "w", encoding="utf-8") as report_file:
|
||||
report_file.write(json.dumps(report))
|
||||
34
primesieve/primesieve_utils.py
Normal file
34
primesieve/primesieve_utils.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""collection of functions to assist in running of primesieve test script"""
|
||||
import os
|
||||
from pathlib import Path
|
||||
import time
|
||||
from zipfile import ZipFile
|
||||
|
||||
import requests
|
||||
|
||||
PRIMESIEVE_FOLDER_NAME = "primesieve-12.3-win-x64"
|
||||
PRIMESIEVE_ZIP_NAME = "primesieve-12.3-win-x64.zip"
|
||||
|
||||
SCRIPT_DIR = Path(os.path.dirname(os.path.realpath(__file__)))
|
||||
|
||||
|
||||
def primesieve_folder_exists() -> bool:
|
||||
"""Check if primesieve has been downloaded or not"""
|
||||
return os.path.isdir(os.path.join(SCRIPT_DIR, PRIMESIEVE_FOLDER_NAME))
|
||||
|
||||
|
||||
def download_primesieve():
|
||||
"""Download and extract primesieve"""
|
||||
download_url = "https://github.com/kimwalisch/primesieve/releases/download/v12.3/primesieve-12.3-win-x64.zip"
|
||||
destination = os.path.join(SCRIPT_DIR, PRIMESIEVE_ZIP_NAME)
|
||||
response = requests.get(download_url, allow_redirects=True, timeout=180)
|
||||
with open(destination, 'wb') as file:
|
||||
file.write(response.content)
|
||||
with ZipFile(destination, 'r') as zip_object:
|
||||
destination_folder = SCRIPT_DIR / PRIMESIEVE_FOLDER_NAME
|
||||
zip_object.extractall(path=destination_folder)
|
||||
|
||||
|
||||
def current_time_ms():
|
||||
"""Get current timestamp in milliseconds since epoch"""
|
||||
return int(time.time() * 1000)
|
||||
Reference in New Issue
Block a user