44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import { simplifyJSCase, origSimplifyJSCase } from './simplifyJS.js'
 | |
| import {
 | |
|   transformToArrayFormCase,
 | |
|   transformToObjectFormCase,
 | |
|   origSimplifyWithTransformCase
 | |
| } from './transforms.js'
 | |
| import {
 | |
|   simplifyWASMCase,
 | |
|   storeCoordsCase,
 | |
|   loadResultCase
 | |
| } from './simplifyWasm.js'
 | |
| 
 | |
| export const chartDependencies = {
 | |
|   wasmStack: [storeCoordsCase, loadResultCase, simplifyWASMCase],
 | |
|   simplifyJSStack: [
 | |
|     origSimplifyWithTransformCase,
 | |
|     transformToArrayFormCase,
 | |
|     transformToObjectFormCase
 | |
|   ],
 | |
|   wasmVsJs: [origSimplifyJSCase, simplifyWASMCase, simplifyJSCase]
 | |
| }
 | |
| 
 | |
| const uniqueFilter = (val, idx, self) => self.indexOf(val) === idx
 | |
| 
 | |
| export function getChartDependencies(chartNames) {
 | |
|   return chartNames
 | |
|     .map(name => chartDependencies[name])
 | |
|     .flat()
 | |
|     .filter(uniqueFilter)
 | |
| }
 | |
| 
 | |
| export function generateCases(data, formState) {
 | |
|   const cases = []
 | |
|   const { tolRange, highQual, chart } = formState
 | |
|   let params = { data, highQuality: highQual }
 | |
|   for (let tol of tolRange) {
 | |
|     params = { ...params, tol }
 | |
|     for (let BenchCaseClass of chartDependencies[chart]) {
 | |
|       cases.push(new BenchCaseClass(params))
 | |
|     }
 | |
|   }
 | |
|   return cases
 | |
| }
 |