Skip to content

Move all samples testing to Rust unit tests - #1739

Merged
Stefan J. Wernli (swernli) merged 8 commits into
mainfrom
swernli/all-samples-to-unit-tests
Jul 23, 2024
Merged

Stefan J. Wernli (swernli) merged 8 commits into
mainfrom
swernli/all-samples-to-unit-tests

Conversation

@swernli

Copy link
Copy Markdown
Contributor

This expands the unit tests in the samples_test folder to include testing of all samples, including compilation of resource estimation samples, compilation of dynamically discovered qsharp.json projects, and compile and run of language samples. With these additions, the build script no longer needs to compile the qsc cmdline tool and can skip the cmdline based compilation of samples, so the build.py file is updated here to remove those.

This expands the unit tests in the samples_test folder to include testing of all samples, including compilation of resource estimation samples, compilation of dynamically discovered qsharp.json projects, and compile and run of language samples. With these additions, the build script no longer needs to compile the qsc cmdline tool and can skip the cmdline based compilation of samples, so the build.py file is updated here to remove those.
@github-actions

Copy link
Copy Markdown

Benchmark for 6b5d87d

Click to view benchmark
Test Base PR %
Array append evaluation 332.9±2.00µs 335.6±1.93µs +0.81%
Array literal evaluation 186.0±0.95µs 186.2±1.76µs +0.11%
Array update evaluation 410.9±2.89µs 412.6±2.84µs +0.41%
Core + Standard library compilation 23.7±0.74ms 21.8±0.64ms -8.02%
Deutsch-Jozsa evaluation 4.7±0.04ms 4.8±0.08ms +2.13%
Large file parity evaluation 34.4±0.17ms 34.9±4.18ms +1.45%
Large input file compilation 13.5±0.85ms 12.4±0.34ms -8.15%
Large input file compilation (interpreter) 52.9±1.12ms 50.6±1.73ms -4.35%
Large nested iteration 32.1±0.15ms 32.4±0.47ms +0.93%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1564.2±63.78µs 1569.3±50.36µs +0.33%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.09ms 7.8±0.08ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1431.9±119.81µs 1427.3±62.45µs -0.32%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.9±0.46ms 27.9±0.25ms 0.00%
Teleport evaluation 90.0±3.24µs 90.0±3.70µs 0.00%

@sezna Alex Hansen (sezna) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really appreciate the scripting being done in build.rs versus some other environment, for the simplicity of cargo test Just Working ™️

@idavis

Copy link
Copy Markdown
Collaborator

Stefan J. Wernli (@swernli) How do I debug a failing test?

@swernli

Copy link
Copy Markdown
Contributor Author

Stefan J. Wernli (@swernli) How do I debug a failing test?

You can debug each module, which will launch the debugger for the tests covered by that module (each test in it's own thread):
image

You can also ctl/cmd + click on the file name in the include macro to jump to the build-time generated file and set breakpoints inside of individual test cases.

@github-actions

Copy link
Copy Markdown

Benchmark for 2720f0b

Click to view benchmark
Test Base PR %
Array append evaluation 337.1±8.52µs 334.9±2.29µs -0.65%
Array literal evaluation 187.8±3.16µs 187.9±4.44µs +0.05%
Array update evaluation 410.4±3.40µs 410.6±6.67µs +0.05%
Core + Standard library compilation 22.0±0.34ms 22.7±0.66ms +3.18%
Deutsch-Jozsa evaluation 4.9±0.05ms 4.9±0.10ms 0.00%
Large file parity evaluation 34.4±0.78ms 34.4±0.71ms 0.00%
Large input file compilation 12.9±0.22ms 12.9±0.48ms 0.00%
Large input file compilation (interpreter) 52.5±1.92ms 51.5±1.63ms -1.90%
Large nested iteration 32.4±0.74ms 32.2±0.37ms -0.62%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1565.6±35.35µs 1536.4±45.97µs -1.87%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.09ms 7.8±0.08ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1424.9±32.37µs 1392.0±40.96µs -2.31%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.8±0.22ms 28.0±1.23ms +0.72%
Teleport evaluation 90.4±3.61µs 90.8±3.49µs +0.44%

@github-actions

Copy link
Copy Markdown

Benchmark for 32a4fba

Click to view benchmark
Test Base PR %
Array append evaluation 333.9±7.07µs 334.2±2.52µs +0.09%
Array literal evaluation 171.7±2.08µs 172.5±1.02µs +0.47%
Array update evaluation 407.9±1.97µs 408.8±2.76µs +0.22%
Core + Standard library compilation 21.4±0.29ms 21.4±0.36ms 0.00%
Deutsch-Jozsa evaluation 5.0±0.07ms 4.9±0.06ms -2.00%
Large file parity evaluation 34.8±0.29ms 34.6±0.33ms -0.57%
Large input file compilation 12.6±0.17ms 12.7±0.25ms +0.79%
Large input file compilation (interpreter) 50.2±1.22ms 50.6±1.58ms +0.80%
Large nested iteration 32.0±0.16ms 32.0±0.25ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1556.3±32.59µs 1565.6±38.96µs +0.60%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.08ms 7.8±0.07ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1417.9±32.31µs 1426.6±50.75µs +0.61%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.9±0.21ms 28.0±1.04ms +0.36%
Teleport evaluation 92.1±3.67µs 92.2±3.59µs +0.11%

@swernli

Copy link
Copy Markdown
Contributor Author

I changed the file generation strategy to split the difference between these being pure build artifacts and being checked in source files. Now the test files are generated to the src folder so they can used and debugged like normal tests, but they are added to the gitignore so that aren't part of the source-controlled content.

@github-actions

Copy link
Copy Markdown

Benchmark for 3f53b24

Click to view benchmark
Test Base PR %
Array append evaluation 339.0±2.93µs 338.6±1.82µs -0.12%
Array literal evaluation 188.6±0.60µs 171.5±0.80µs -9.07%
Array update evaluation 410.4±3.09µs 409.0±3.60µs -0.34%
Core + Standard library compilation 22.5±0.61ms 21.5±0.68ms -4.44%
Deutsch-Jozsa evaluation 4.9±0.05ms 4.9±0.11ms 0.00%
Large file parity evaluation 34.5±0.30ms 34.5±0.28ms 0.00%
Large input file compilation 12.6±0.28ms 13.1±0.46ms +3.97%
Large input file compilation (interpreter) 50.8±1.88ms 52.0±1.98ms +2.36%
Large nested iteration 32.2±0.18ms 32.0±0.16ms -0.62%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1555.8±27.81µs 1565.2±53.09µs +0.60%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.11ms 7.9±0.13ms +1.28%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1427.6±76.81µs 1429.9±67.86µs +0.16%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.1±1.21ms 28.2±0.46ms +0.36%
Teleport evaluation 90.5±3.47µs 91.5±3.67µs +1.10%

@github-actions

Copy link
Copy Markdown

Benchmark for b08b9a9

Click to view benchmark
Test Base PR %
Array append evaluation 335.5±5.49µs 381.6±3.06µs +13.74%
Array literal evaluation 181.1±4.31µs 189.7±1.54µs +4.75%
Array update evaluation 410.9±3.78µs 438.8±2.82µs +6.79%
Core + Standard library compilation 21.3±0.27ms 21.6±0.38ms +1.41%
Deutsch-Jozsa evaluation 4.9±0.07ms 4.9±0.07ms 0.00%
Large file parity evaluation 34.6±0.32ms 34.4±0.33ms -0.58%
Large input file compilation 12.6±0.21ms 12.6±0.22ms 0.00%
Large input file compilation (interpreter) 50.4±1.11ms 50.3±1.44ms -0.20%
Large nested iteration 32.1±0.24ms 35.3±0.65ms +9.97%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1559.1±37.65µs 1571.4±36.77µs +0.79%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.9±0.12ms 7.9±0.12ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1422.3±34.13µs 1428.1±37.97µs +0.41%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.9±0.22ms 27.9±0.27ms 0.00%
Teleport evaluation 94.0±3.36µs 92.2±3.71µs -1.91%

@github-actions

Copy link
Copy Markdown

Benchmark for 17af7d2

Click to view benchmark
Test Base PR %
Array append evaluation 335.5±14.28µs 335.2±2.55µs -0.09%
Array literal evaluation 175.0±22.21µs 189.5±1.09µs +8.29%
Array update evaluation 408.4±15.38µs 408.4±1.27µs 0.00%
Core + Standard library compilation 23.0±0.67ms 22.8±0.69ms -0.87%
Deutsch-Jozsa evaluation 4.9±0.10ms 4.9±0.05ms 0.00%
Large file parity evaluation 34.5±0.26ms 34.6±0.58ms +0.29%
Large input file compilation 13.2±0.32ms 13.2±0.40ms 0.00%
Large input file compilation (interpreter) 53.7±2.09ms 52.8±1.58ms -1.68%
Large nested iteration 32.2±1.97ms 32.1±0.15ms -0.31%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1578.0±45.54µs 1581.3±79.64µs +0.21%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.0±0.11ms 7.9±0.10ms -1.25%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1441.8±68.35µs 1442.6±111.00µs +0.06%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.1±0.22ms 28.1±0.37ms 0.00%
Teleport evaluation 90.9±3.46µs 90.5±3.58µs -0.44%

@github-actions

Copy link
Copy Markdown

Benchmark for 5c7be98

Click to view benchmark
Test Base PR %
Array append evaluation 337.4±2.97µs 338.1±9.67µs +0.21%
Array literal evaluation 173.3±3.73µs 189.2±0.81µs +9.17%
Array update evaluation 411.6±1.75µs 413.6±2.50µs +0.49%
Core + Standard library compilation 21.8±0.37ms 22.1±0.72ms +1.38%
Deutsch-Jozsa evaluation 4.9±0.15ms 4.9±0.06ms 0.00%
Large file parity evaluation 34.5±0.30ms 34.6±0.43ms +0.29%
Large input file compilation 12.8±0.20ms 13.0±0.91ms +1.56%
Large input file compilation (interpreter) 51.3±1.67ms 51.2±1.42ms -0.19%
Large nested iteration 32.5±0.44ms 32.4±0.15ms -0.31%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1570.3±37.82µs 1567.4±38.84µs -0.18%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.9±0.13ms 7.9±0.11ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1429.3±33.45µs 1428.7±45.52µs -0.04%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.1±0.27ms 27.9±0.24ms -0.71%
Teleport evaluation 90.5±3.18µs 91.0±4.85µs +0.55%

@swernli
Stefan J. Wernli (swernli) added this pull request to the merge queue Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants