Skip to content
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

perf!: improve performance by replacing Character with Unicode.Scalar #63

Merged
merged 3 commits into from
May 2, 2024

Conversation

kkebo
Copy link
Owner

@kkebo kkebo commented May 2, 2024

refs #61

==================                                                                                                                                                                                                  
Running Benchmarks                                                                                                                                                                                                  
==================                                                                                                                                                                                                  
                                                                                                                                                                                                                    
100% [------------------------------------------------------------] ETA: 00:00:00 | MyBenchmark:lipsum                                                                                                              
100% [------------------------------------------------------------] ETA: 00:00:00 | MyBenchmark:lipsum-zh                                                                                                           
100% [------------------------------------------------------------] ETA: 00:00:00 | MyBenchmark:medium-fragment                                                                                                     
100% [------------------------------------------------------------] ETA: 00:00:00 | MyBenchmark:small-fragment                                                                                                      
100% [------------------------------------------------------------] ETA: 00:00:00 | MyBenchmark:strong                                                                                                              
100% [------------------------------------------------------------] ETA: 00:00:00 | MyBenchmark:tiny-fragment                                                                                                       
                                                                                                                                                                                                                    
===================================================                                                                                                                                                                 
Comparing results between 'main' and 'Current_run'                                                                                                                                                                  
===================================================                                                                                                                                                                 
                                                                                                                                                                                                                    
Host 'Brown-rhinoceros-beetle' with 8 'aarch64' processors with 7 GB memory, running:                                                                                                                               
#1 SMP PREEMPT_DYNAMIC Wed Apr 24 00:11:34 UTC 2024                                                                                                                                                                 
                                                                                                                                                                                                                    
MyBenchmark                                                                                                                                                                                                         
============================================================================================================================                                                                                        
                                                                                                                                                                                                                    
----------------------------------------------------------------------------------------------------------------------------                                                                                        
lipsum metrics                                                                                                                                                                                                      
----------------------------------------------------------------------------------------------------------------------------                                                                                        
                                                                                                                                                                                                                    
╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕                                                                                        
│         Time (wall clock) (μs) *         │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │                                                                                        
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡                                                                                        
│                   main                   │     775 │     775 │     776 │     782 │     783 │     784 │     784 │      78 │                                                                                        
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤                                                                                        
│               Current_run                │     112 │     112 │     112 │     113 │     115 │     118 │     119 │     100 │                                                                                        
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤                                                                                        
│                    Δ                     │    -663 │    -663 │    -664 │    -669 │    -668 │    -666 │    -665 │      22 │                                                                                        
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤                                                                                        
│              Improvement %               │      86 │      86 │      86 │      86 │      85 │      85 │      85 │      22 │                                                                                        
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛                                                                                        
                                                                                                                                                                                                                    
----------------------------------------------------------------------------------------------------------------------------                                                                                        
lipsum-zh metrics                                                                                                                                                                                                   
----------------------------------------------------------------------------------------------------------------------------                                                                                        
                                                                                                                                                                                                                    
╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕                                                                                        
│         Time (wall clock) (μs) *         │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │                                                                                        
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡                                                                                        
│                   main                   │     153 │     153 │     153 │     153 │     154 │     160 │     161 │     100 │                                                                                        
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤                                                                                        
│               Current_run                │      14 │      14 │      14 │      14 │      14 │      15 │      15 │     100 │                                                                                        
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤                                                                                        
│                    Δ                     │    -139 │    -139 │    -139 │    -139 │    -140 │    -145 │    -146 │       0 │                                                                     
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      91 │      91 │      91 │      91 │      91 │      91 │      91 │       0 │                                                                     
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

----------------------------------------------------------------------------------------------------------------------------                                                                     
medium-fragment metrics
----------------------------------------------------------------------------------------------------------------------------                                                                     

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│         Time (wall clock) (μs) *         │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │                                                                     
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │     357 │     358 │     358 │     358 │     365 │     366 │     366 │     100 │                                                                     
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│               Current_run                │     137 │     137 │     137 │     138 │     141 │     143 │     144 │     100 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤                                                                     
│                    Δ                     │    -220 │    -221 │    -221 │    -220 │    -224 │    -223 │    -222 │       0 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤                                                                     
│              Improvement %               │      62 │      62 │      62 │      61 │      61 │      61 │      61 │       0 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

----------------------------------------------------------------------------------------------------------------------------
small-fragment metrics
----------------------------------------------------------------------------------------------------------------------------

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│         Time (wall clock) (μs) *         │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │      57 │      57 │      57 │      58 │      58 │      62 │      62 │     100 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│               Current_run                │      18 │      18 │      18 │      18 │      18 │      19 │      19 │     100 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │     -39 │     -39 │     -39 │     -40 │     -40 │     -43 │     -43 │       0 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      68 │      68 │      68 │      69 │      69 │      69 │      69 │       0 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

----------------------------------------------------------------------------------------------------------------------------
strong metrics
----------------------------------------------------------------------------------------------------------------------------

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│         Time (wall clock) (μs) *         │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │     100 │     100 │     100 │     100 │     101 │     107 │     110 │     100 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│               Current_run                │      39 │      39 │      39 │      40 │      40 │      42 │      42 │     100 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │     -61 │     -61 │     -61 │     -60 │     -61 │     -65 │     -68 │       0 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      61 │      61 │      61 │      60 │      60 │      61 │      62 │       0 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

----------------------------------------------------------------------------------------------------------------------------
tiny-fragment metrics
----------------------------------------------------------------------------------------------------------------------------

╒══════════════════════════════════════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╤═════════╕
│         Time (wall clock) (ns) *         │      p0 │     p25 │     p50 │     p75 │     p90 │     p99 │    p100 │ Samples │
╞══════════════════════════════════════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╪═════════╡
│                   main                   │    1599 │    1604 │    1658 │    1663 │    1717 │    1855 │    1855 │     100 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│               Current_run                │     509 │     521 │     529 │     549 │     591 │     685 │     688 │     100 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│                    Δ                     │   -1090 │   -1083 │   -1129 │   -1114 │   -1126 │   -1170 │   -1167 │       0 │
├──────────────────────────────────────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┼─────────┤
│              Improvement %               │      68 │      68 │      68 │      67 │      66 │      63 │      63 │       0 │
╘══════════════════════════════════════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╧═════════╛

@kkebo kkebo added the enhancement New feature or request label May 2, 2024
@kkebo kkebo self-assigned this May 2, 2024
Copy link
Contributor

github-actions bot commented May 2, 2024

Code Metrics Report

main (1b292dd) #63 (7fd508a) +/-
Coverage 88.4% 89.1% +0.7%
Details
  |           | main (1b292dd) | #63 (7fd508a) |  +/-  |
  |-----------|----------------|---------------|-------|
+ | Coverage  |          88.4% |         89.1% | +0.7% |
  |   Files   |              7 |             7 |     0 |
  |   Lines   |           1255 |          1308 |   +53 |
+ |   Covered |           1110 |          1166 |   +56 |

Code coverage of files in pull request scope (88.2% → 88.9%)

Files Coverage +/-
Sources/Tokenizer/CharRefTokenizer.swift 97.7% +0.0%
Sources/Tokenizer/Tokenizer.swift 87.0% +1.0%
Sources/Tokenizer/Utils.swift 100.0% 0.0%

Reported by octocov

@kkebo kkebo merged commit fc60b98 into main May 2, 2024
2 checks passed
@kkebo kkebo deleted the unicode-scalar branch May 2, 2024 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant