elixir-gettext/expo

Performance Comparison with Gettext

maennchen opened this issue · 2 comments

⚠️ Currently, this library is not performance optimized at all.

Based on: https://github.com/jshmrtn/expo/tree/performance_comparisor/performance_test

read.exs
Operating System: Linux
CPU Information: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Number of Available Cores: 8
Available memory: 46.77 GB
Elixir 1.13.3
Erlang 24.3.3

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 42 s

Benchmarking Expo.Parser.Mo.parse ...
Benchmarking Expo.Parser.Po.parse ...
Benchmarking Gettext.PO.parse_string ...

Name                              ips        average  deviation         median         99th %
Expo.Parser.Mo.parse           525.98        1.90 ms    ±24.75%        1.81 ms        2.80 ms
Gettext.PO.parse_string        116.38        8.59 ms    ±10.98%        8.77 ms       10.80 ms
Expo.Parser.Po.parse            62.41       16.02 ms    ±13.50%       15.61 ms       23.78 ms

Comparison: 
Expo.Parser.Mo.parse           525.98
Gettext.PO.parse_string        116.38 - 4.52x slower +6.69 ms
Expo.Parser.Po.parse            62.41 - 8.43x slower +14.12 ms

Memory usage statistics:

Name                       Memory usage
Expo.Parser.Mo.parse            1.57 MB
Gettext.PO.parse_string        10.35 MB - 6.59x memory usage +8.78 MB
Expo.Parser.Po.parse           45.78 MB - 29.12x memory usage +44.21 MB

**All measurements for memory usage were the same**
write.exs
Operating System: Linux
CPU Information: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Number of Available Cores: 8
Available memory: 46.77 GB
Elixir 1.13.3
Erlang 24.3.3

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 42 s

Benchmarking Expo.Composer.Mo.compose ...
Benchmarking Expo.Composer.Po.compose ...
Benchmarking Gettext.PO.dump ...

Name                               ips        average  deviation         median         99th %
Expo.Composer.Mo.compose       2354.75        0.42 ms    ±19.23%        0.40 ms        0.84 ms
Gettext.PO.dump                 148.69        6.73 ms    ±17.47%        6.54 ms        9.87 ms
Expo.Composer.Po.compose        136.89        7.30 ms    ±34.08%        6.64 ms       16.90 ms

Comparison: 
Expo.Composer.Mo.compose       2354.75
Gettext.PO.dump                 148.69 - 15.84x slower +6.30 ms
Expo.Composer.Po.compose        136.89 - 17.20x slower +6.88 ms

Memory usage statistics:

Name                        Memory usage
Expo.Composer.Mo.compose         0.50 MB
Gettext.PO.dump                  3.59 MB - 7.19x memory usage +3.10 MB
Expo.Composer.Po.compose         3.81 MB - 7.63x memory usage +3.31 MB

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

Comparison is based on the follwoing gettext file and its mo counterpart: https://github.com/jshmrtn/hygeia/blob/4f08c2b68f5de8cad6a84b9d4a0b01be63a7c32c/priv/gettext/de/LC_MESSAGES/default.po

It contains 6'355 lines of po content for 1'398 translations + the header.

Update with a few performance improvements & disabled new features:

Operating System: Linux
CPU Information: 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Number of Available Cores: 8
Available memory: 46.77 GB
Elixir 1.13.3
Erlang 24.3.3

Benchmark suite executing with the following configuration:
warmup: 2 s
time: 10 s
memory time: 2 s
reduction time: 0 ns
parallel: 1
inputs: none specified
Estimated total run time: 42 s

Benchmarking Expo.Parser.Mo.parse ...
Benchmarking Expo.Parser.Po.parse ...
Benchmarking Gettext.PO.parse_string ...

Name                              ips        average  deviation         median         99th %
Expo.Parser.Mo.parse           345.16        2.90 ms    ±30.48%        2.90 ms        5.35 ms
Gettext.PO.parse_string         89.65       11.15 ms    ±39.70%        9.24 ms       28.10 ms
Expo.Parser.Po.parse            68.48       14.60 ms     ±6.82%       14.58 ms       18.05 ms

Comparison: 
Expo.Parser.Mo.parse           345.16
Gettext.PO.parse_string         89.65 - 3.85x slower +8.26 ms
Expo.Parser.Po.parse            68.48 - 5.04x slower +11.71 ms

Memory usage statistics:

Name                       Memory usage
Expo.Parser.Mo.parse            1.57 MB
Gettext.PO.parse_string        10.35 MB - 6.59x memory usage +8.78 MB
Expo.Parser.Po.parse           40.20 MB - 25.57x memory usage +38.63 MB

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

No longer relevant because of #25