Changes between Version 1 and Version 2 of Ticket #34521
- Timestamp:
- Apr 27, 2023, 1:58:19 AM (19 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #34521 – Description
v1 v2 5 5 #33474 added __slots__ to `Variable` and related classes, showing memory reductions and performance gains. 6 6 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:7 I 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: 8 8 9 9 {{{ … … 31 31 --prepare 'git switch -d 7d0e566208' \ 32 32 'python benchmark.py' \ 33 --prepare 'git switch optimize_templates' \33 --prepare 'git switch ticket_34521_optimize_templates' \ 34 34 'python benchmark.py' 35 35 Benchmark 1: python benchmark.py 36 Time (mean ± σ): 2.0 06 s ± 0.007 s [User: 1.968s, System: 0.035 s]37 Range (min … max): 1.99 5 s … 2.013s 10 runs36 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 38 38 39 39 Benchmark 2: python benchmark.py 40 Time (mean ± σ): 1.9 93 s ± 0.008 s [User: 1.958 s, System: 0.034s]41 Range (min … max): 1.9 84 s … 2.012s 10 runs40 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 42 42 43 43 Summary 44 44 'python benchmark.py' ran 45 1.0 1 ± 0.01times faster than 'python benchmark.py'45 1.02 ± 0.02 times faster than 'python benchmark.py' 46 46 }}} 47 48 (I decided not to use djangobench since it's not well maintained, and doesn't do such great stats as hyperfine.)