-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from tscircuit/benchmark
Benchmark
- Loading branch information
Showing
5 changed files
with
132 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ dist | |
*.bettereasy.json | ||
.vscode | ||
tmp | ||
temp.tsx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { readFile, writeFile } from "node:fs/promises" | ||
import { convertEasyEdaJsonToVariousFormats } from "../lib/convert-easyeda-json-to-various-formats" | ||
import path from "node:path" | ||
|
||
async function benchmark() { | ||
const partnumbersPath = path.join(__dirname, "partnumbers.json") | ||
const resultPath = path.join(__dirname, "result.txt") | ||
|
||
let partnumbers: string[] | ||
try { | ||
const data = await readFile(partnumbersPath, "utf-8") | ||
partnumbers = JSON.parse(data) | ||
} catch (error) { | ||
console.error("Error reading partnumbers.json:", error) | ||
return | ||
} | ||
|
||
let successes = 0 | ||
let failures = 0 | ||
let failureLog = "" | ||
|
||
for (const partnumber of partnumbers) { | ||
try { | ||
await convertEasyEdaJsonToVariousFormats({ | ||
jlcpcbPartNumberOrFilepath: partnumber, | ||
outputFilename: "temp.tsx", | ||
formatType: "tsx", | ||
}) | ||
successes++ | ||
} catch (error) { | ||
failures++ | ||
failureLog += `Part number: ${partnumber}\nError: ${error}\n\n` | ||
} | ||
} | ||
|
||
const summary = `Successes: ${successes}\nFailures: ${failures}\n\nFailure Details:\n${failureLog}` | ||
|
||
try { | ||
await writeFile(resultPath, summary) | ||
console.log(`Benchmark complete. Results written to ${resultPath}`) | ||
console.log(`Successes: ${successes}`) | ||
console.log(`Failures: ${failures}`) | ||
} catch (error) { | ||
console.error("Error writing result.txt:", error) | ||
} | ||
} | ||
|
||
benchmark() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[ | ||
"C21376", | ||
"C25744", | ||
"C965808", | ||
"C14663", | ||
"C1178474", | ||
"C1153543", | ||
"C1177579", | ||
"C1184469", | ||
"C1185108", | ||
"C1180645", | ||
"C1189664", | ||
"C1178711", | ||
"C389354", | ||
"C516304", | ||
"C2998002", | ||
"C74384", | ||
"C11702", | ||
"C94784", | ||
"C72044", | ||
"C49678", | ||
"C25804", | ||
"C26083", | ||
"C2843864", | ||
"C2040" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
Successes: 11 | ||
Failures: 13 | ||
|
||
Failure Details: | ||
Part number: C965808 | ||
Error: Error: Invalid shape type: PT~M 245 303 L 235 310 L 245 317 Z ~#880000~1~0~none~gge49~0~ | ||
|
||
Part number: C1178474 | ||
Error: Error: Component not found | ||
|
||
Part number: C1153543 | ||
Error: Error: Component not found | ||
|
||
Part number: C1177579 | ||
Error: Error: Component not found | ||
|
||
Part number: C1184469 | ||
Error: Error: Component not found | ||
|
||
Part number: C1185108 | ||
Error: Error: Component not found | ||
|
||
Part number: C1180645 | ||
Error: Error: Component not found | ||
|
||
Part number: C1189664 | ||
Error: Error: Component not found | ||
|
||
Part number: C1178711 | ||
Error: Error: Component not found | ||
|
||
Part number: C389354 | ||
Error: Error: Invalid shape type: PT~M 405 294 L 395 300 L 405 307 Z ~#880000~1~0~none~gge18~0~ | ||
|
||
Part number: C516304 | ||
Error: Error: Invalid shape type: PT~M 395 326 L 405 320 L 395 313 Z~#880000~1~0~#880000~gge25~0~ | ||
|
||
Part number: C2998002 | ||
Error: Error: Invalid shape type: T~L~415~303~0~#0000FF~~5.5pt~~~~comment~TR1~1~start~gge7~0~pinpart | ||
|
||
Part number: C2843864 | ||
Error: Error: Invalid shape type: PT~M 420 337 L 430 330 L 420 323 Z ~#880000~1~0~none~gge82~0~ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters