bitovi / academy

Everything we know about frontend, backend, UX, and Devops consulting and management.
https://www.bitovi.com/academy/
14 stars 3 forks source link

Run the tests in parallel #771

Closed chasenlehara closed 1 month ago

chasenlehara commented 1 month ago

This improves the time it takes to run the exercise solution tests by running them in parallel.

Below are the results of multiple test runs in GitHub and on a MacBook Pro. It looks like about three tests running in parallel is optimal in both environments, so the test script will max out at running three tests at a time.

First run in GitHub CI:

┌─────────┬───────┬───────────────┬─────────────┐
│ (index) │ limit │ time          │ formatted   │
├─────────┼───────┼───────────────┼─────────────┤
│ 0       │ 4     │ 787608.631378 │ '13:07.608' │
│ 1       │ 3     │ 461751.497619 │ '7:41.751'  │
│ 2       │ 2     │ 475695.005603 │ '7:55.695'  │
│ 3       │ 1     │ 646006.242796 │ '10:46.006' │
└─────────┴───────┴───────────────┴─────────────┘

Second run (after changing the max limit after realizing the first run will be slower while priming the npm cache):

┌─────────┬───────┬───────────────┬─────────────┐
│ (index) │ limit │ time          │ formatted   │
├─────────┼───────┼───────────────┼─────────────┤
│ 0       │ 5     │ 763990.330012 │ '12:43.990' │
│ 1       │ 4     │ 432908.429822 │ '7:12.908'  │
│ 2       │ 3     │ 445064.747047 │ '7:25.064'  │
│ 3       │ 2     │ 468414.323292 │ '7:48.414'  │
│ 4       │ 1     │ 639965.18994  │ '10:39.965' │
└─────────┴───────┴───────────────┴─────────────┘

First run on a MacBook Pro:

┌─────────┬───────┬───────────────┬─────────────┐
│ (index) │ limit │ time          │ formatted   │
├─────────┼───────┼───────────────┼─────────────┤
│ 0       │ 8     │ 666539.938417 │ '11:06.539' │
│ 1       │ 7     │ 607849.072083 │ '10:07.849' │
│ 2       │ 6     │ 571706.310166 │ '9:31.706'  │
│ 3       │ 5     │ 516670.640167 │ '8:36.670'  │
│ 4       │ 4     │ 498700.136167 │ '8:18.700'  │
│ 5       │ 3     │ 471225.195584 │ '7:51.225'  │
│ 6       │ 2     │ 485589.121083 │ '8:05.589'  │
│ 7       │ 1     │ 617190.439583 │ '10:17.190' │
└─────────┴───────┴───────────────┴─────────────┘

Second run:

┌─────────┬───────┬───────────────┬─────────────┐
│ (index) │ limit │ time          │ formatted   │
├─────────┼───────┼───────────────┼─────────────┤
│ 0       │ 8     │ 653896.0615   │ '10:53.896' │
│ 1       │ 7     │ 578432.966958 │ '9:38.432'  │
│ 2       │ 6     │ 550287.004208 │ '9:10.287'  │
│ 3       │ 5     │ 509471.244167 │ '8:29.471'  │
│ 4       │ 4     │ 497503.24975  │ '8:17.503'  │
│ 5       │ 3     │ 468895.376833 │ '7:48.895'  │
│ 6       │ 2     │ 492863.924542 │ '8:12.863'  │
│ 7       │ 1     │ 615069.0665   │ '10:15.069' │
└─────────┴───────┴───────────────┴─────────────┘
DanDaManTran commented 1 month ago
Screenshot 2024-05-20 at 10 48 51 AM

Test is failing when running benchmark. It pass successfully without benchmark

chasenlehara commented 1 month ago

Test is failing when running benchmark. It pass successfully without benchmark

Interesting, I ran into this too at parallel limits 9+ (my Mac as 10 cores). I don’t think this matters for merging it in because I left the benchmark code mainly as a reference for doing something similar in the future.