Changes between Version 1 and Version 2 of Ticket #34521


Ignore:
Timestamp:
Apr 27, 2023, 1:58:19 AM (13 months ago)
Author:
Adam Johnson
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34521 – Description

    v1 v2  
    55#33474 added __slots__ to `Variable` and related classes, showing memory reductions and performance gains.
    66
    7 I propose adding __slots__ to more template classes to further save memory (Template, Token, Lexer, and the Node classes). This change leads to about a 1% improvement in template rendering time, using this benchmark script:
     7I propose adding __slots__ to more template classes to further save memory (Template, Token, Lexer, and the Node classes). This change leads to 1-2% improvement in template rendering time, using this benchmark script:
    88
    99{{{
     
    3131  --prepare 'git switch -d 7d0e566208' \
    3232  'python benchmark.py' \
    33   --prepare 'git switch optimize_templates' \
     33  --prepare 'git switch ticket_34521_optimize_templates' \
    3434  'python benchmark.py'
    3535Benchmark 1: python benchmark.py
    36   Time (mean ± σ):      2.006 s ±  0.007 s    [User: 1.968 s, System: 0.035 s]
    37   Range (min … max):    1.995 s …  2.013 s    10 runs
     36  Time (mean ± σ):      2.028 s ±  0.042 s    [User: 1.990 s, System: 0.035 s]
     37  Range (min … max):    1.997 s …  2.116 s    10 runs
    3838
    3939Benchmark 2: python benchmark.py
    40   Time (mean ± σ):      1.993 s ±  0.008 s    [User: 1.958 s, System: 0.034 s]
    41   Range (min … max):    1.984 s …  2.012 s    10 runs
     40  Time (mean ± σ):      1.985 s ±  0.007 s    [User: 1.950 s, System: 0.033 s]
     41  Range (min … max):    1.976 s …  1.997 s    10 runs
    4242
    4343Summary
    4444  'python benchmark.py' ran
    45     1.01 ± 0.01 times faster than 'python benchmark.py'
     45    1.02 ± 0.02 times faster than 'python benchmark.py'
    4646}}}
     47
     48(I decided not to use djangobench since it's not well maintained, and doesn't do such great stats as hyperfine.)
Back to Top