yum/vfft
git clone https://git.yummers.dev/yum/vfft
fbfe6b0
master
1#!/usr/bin/env -S uv run --script 2# 3# /// script 4# requires-python = ">=3.12" 5# dependencies = [] 6# /// 7 8# Exports latest Criterion results to a .csv file. 9 10import argparse 11import csv 12from datetime import date 13import json 14import subprocess 15from pathlib import Path 16 17def parse_args (): 18parser = argparse .ArgumentParser (description = "Convert latest Criterion results to CSV." ) 19parser .add_argument ("suffix" ,help = "CSV filename suffix, e.g. 9800x3d" ) 20args = parser .parse_args () 21return args 22 23def filename (args ): 24cmd = ["git" ,"rev-parse" ,"--short=16" ,"HEAD" ] 25commit = subprocess .check_output (cmd ,text = True ).strip () 26return f" { commit } _ { args . suffix } .csv" 27 28def get_save_path (args ): 29measurements = Path (__file__ ).resolve ().parent 30return measurements / filename (args ) 31 32def parse_data (args ): 33script_dir = Path (__file__ ).resolve () 34project_root = script_dir .parents [1 ] 35criterion = project_root / "target/criterion" 36files = list (criterion .glob ("size *, fft v8/new/estimates.json" )) 37latest_date = max (date .fromtimestamp (path .stat ().st_mtime )for path in files ) 38data = [] 39for path in files : 40# Ignore sizes left over from runs on earlier dates. 41if date .fromtimestamp (path .stat ().st_mtime )!= latest_date : 42continue 43size = int (path .parent .parent .name .split ("," )[0 ].split ()[1 ]) 44row = [size ] 45for implementation in ["reference" ,"fft v8" ]: 46estimates_path = criterion / f"size { size } , { implementation } /new/estimates.json" 47assert date .fromtimestamp (estimates_path .stat ().st_mtime )== latest_date 48estimates = json .loads (estimates_path .read_text ()) 49row .append (estimates ["slope" ]["point_estimate" ]) 50data .append (row ) 51return sorted (data ) 52 53def main (): 54args = parse_args () 55data = parse_data (args ) 56with open (get_save_path (args ),"w" ,newline = "" ,encoding = "utf-8" )as file : 57writer = csv .writer (file ,lineterminator = "\n" ) 58writer .writerow (["Input length" ,"rustfft" ,"vfft (fft v8)" ]) 59writer .writerows (data ) 60filename (args )) 61 62if __name__ == "__main__" : 63main () 64