Skip to content

Add compile time warnings #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2025
Merged

Add compile time warnings #22

merged 1 commit into from
Jul 31, 2025

Conversation

Schultzer
Copy link
Member

@Schultzer Schultzer commented Jul 31, 2025

➜  sql git:(add-compile-time-warnings) ✗ mix sql.bench
Operating System: macOS
CPU Information: Apple M1 Max
Number of Available Cores: 10
Available memory: 64 GB
Elixir 1.18.3
Erlang 27.3.3
JIT enabled: true

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 5 s
memory time: 2 s
reduction time: 2 s
parallel: 1
inputs: 1..100_000
Estimated total run time: 1 min 50 s

Benchmarking comptime ecto with input 1..100_000 ...
Benchmarking comptime inspect with input 1..100_000 ...
Benchmarking comptime to_sql with input 1..100_000 ...
Benchmarking comptime to_string with input 1..100_000 ...
Benchmarking lex with input 1..100_000 ...
Benchmarking parse with input 1..100_000 ...
Benchmarking runtime ecto with input 1..100_000 ...
Benchmarking runtime inspect with input 1..100_000 ...
Benchmarking runtime to_sql with input 1..100_000 ...
Benchmarking runtime to_string with input 1..100_000 ...
Calculating statistics...
Formatting results...

##### With input 1..100_000 #####
Name                         ips        average  deviation         median         99th %
runtime to_sql           21.87 M       45.72 ns ±31291.17%          42 ns          42 ns
comptime to_sql          21.61 M       46.26 ns ±33275.33%          42 ns          42 ns
runtime to_string        21.19 M       47.20 ns ±41503.82%          42 ns          42 ns
comptime to_string       21.18 M       47.22 ns ±41317.85%          42 ns          42 ns
comptime inspect          6.69 M      149.46 ns ±15736.13%         125 ns         208 ns
runtime inspect           6.64 M      150.55 ns ±15368.64%         125 ns         208 ns
parse                     1.34 M      747.48 ns  ±2675.29%         708 ns         875 ns
lex                       0.23 M     4315.61 ns   ±214.62%        4167 ns        5291 ns
comptime ecto             0.20 M     4880.88 ns   ±221.87%        4667 ns        6917 ns
runtime ecto             0.193 M     5172.97 ns   ±180.30%        4959 ns        7500 ns

Comparison: 
runtime to_sql           21.87 M
comptime to_sql          21.61 M - 1.01x slower +0.54 ns
runtime to_string        21.19 M - 1.03x slower +1.47 ns
comptime to_string       21.18 M - 1.03x slower +1.50 ns
comptime inspect          6.69 M - 3.27x slower +103.74 ns
runtime inspect           6.64 M - 3.29x slower +104.82 ns
parse                     1.34 M - 16.35x slower +701.75 ns
lex                       0.23 M - 94.39x slower +4269.89 ns
comptime ecto             0.20 M - 106.75x slower +4835.16 ns
runtime ecto             0.193 M - 113.14x slower +5127.25 ns

Memory usage statistics:

Name                  Memory usage
runtime to_sql                24 B
comptime to_sql               24 B - 1.00x memory usage +0 B
runtime to_string              0 B - 0.00x memory usage -24 B
comptime to_string             0 B - 0.00x memory usage -24 B
comptime inspect             280 B - 11.67x memory usage +256 B
runtime inspect              280 B - 11.67x memory usage +256 B
parse                       2736 B - 114.00x memory usage +2712 B
lex                        11984 B - 499.33x memory usage +11960 B
comptime ecto              18848 B - 785.33x memory usage +18824 B
runtime ecto               21336 B - 889.00x memory usage +21312 B

**All measurements for memory usage were the same**

Reduction count statistics:

Name               Reduction count
runtime to_sql                   2
comptime to_sql                  2 - 1.00x reduction count +0
runtime to_string                7 - 3.50x reduction count +5
comptime to_string               7 - 3.50x reduction count +5
comptime inspect                28 - 14.00x reduction count +26
runtime inspect                 28 - 14.00x reduction count +26
parse                          255 - 127.50x reduction count +253
lex                            154 - 77.00x reduction count +152
comptime ecto                 1132 - 566.00x reduction count +1130
runtime ecto                  1193 - 596.50x reduction count +1191

**All measurements for reduction count were the same**
Screenshot 2025-07-31 at 2 24 13 PM Screenshot 2025-07-31 at 2 21 25 PM

@Schultzer Schultzer merged commit bef240e into main Jul 31, 2025
4 checks passed
@Schultzer Schultzer deleted the add-compile-time-warnings branch July 31, 2025 18:25
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.

1 participant