libinjection-go icon indicating copy to clipboard operation
libinjection-go copied to clipboard

draft: performance refactor

Open jptosso opened this issue 3 months ago • 2 comments

Performance:

Speed: 3-10% faster across all benchmarks Memory: 0.2-1.1% reduction in bytes allocated Throughput: 2x (100%+) improvement in operations per second

Other improvements:

  • Code Quality: More idiomatic Go, less C-style
                            ORIGINAL  →  OPTIMIZED     IMPROVEMENT
SQLi Detection:
  Speed (ns/op):               39,444  →     35,312      10.5% faster
  Memory (B/op):               49,888  →     49,360       1.1% less
  Allocations:                    321  →        395      23% more
  Throughput (ops/10s):       155,161  →    339,213     118.6% more

Folding:
  Speed (ns/op):               99,207  →     91,912       7.4% faster
  Memory (B/op):               71,112  →     70,624       0.7% less
  Allocations:                  1,775  →      1,755       1.1% less
  Throughput (ops/10s):        61,015  →    125,456     105.7% more

Tokenization:
  Speed (ns/op):              165,441  →    159,822       3.4% faster
  Memory (B/op):              149,929  →    149,561       0.2% less
  Allocations:                  3,689  →      3,689      Same
  Throughput (ops/10s):        36,444  →     75,534     107.2% more

XSS Detection:
  Speed (ns/op):               54,036  →     53,522       0.9% faster
  Memory (B/op):               49,016  →     49,016      Identical
  Allocations:                  1,179  →      1,179      Identical
  Throughput (ops/10s):       110,212  →    224,968     104.1% more

jptosso avatar Oct 15 '25 11:10 jptosso

Can we split this one?

fzipi avatar Nov 17 '25 12:11 fzipi