Commit 0282c25
authored
[decode-syseeprom] Optimize startup performance with lazy imports (#4092)
The background is decode-syseeprom script had slow startup time due to expensive imports at the top level.
- What I did
Moved sonic_platform imports into the function that use it.
For the command "show platform syseeprom", sonic_platform is never imported, saving ~200ms.
- How I did it
Implemented lazy import pattern for sonic_platform.
Because TlvInfoDecoder still need to be used in command "show platform syseeprom", so still keep it.
- How to verify it
Before lazy import update:
admin@sonic:~$ time show platform syseeprom
...
real 0m2.064s
user 0m1.242s
sys 0m0.269s
After lazy import update:
admin@sonic:~$ time show platform syseeprom
...
real 0m1.807s
user 0m1.255s
sys 0m0.285s
Can save ~200ms.1 parent 3035299 commit 0282c25
2 files changed
+7
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
20 | 19 | | |
21 | 20 | | |
22 | 21 | | |
| |||
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
212 | 212 | | |
213 | 213 | | |
214 | 214 | | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
0 commit comments