-
Notifications
You must be signed in to change notification settings - Fork 2
Performance
I've been enhancing the techniques to cache the data, ever since the release of Iconit v4
. Finally abled to implement a faster way to do so and here's why the upcoming release is going to be much faster in terms of the caching performance. The process goes as follows:
- Read PS4 directories' names for
GAME IDs
. - Fetch
IDs
according to user's choice of the homebrews turned on/off. - Filter out the empty folders or the once don't contain icons.
- Fetch
GAME TITLE
:- If found in DB.
- If not found read
pronounciation.xml
from game folder.
- Store
game ids
game titles
cache inJSON
The following performance recorded by CProfiler Python 3.11
. Shows how many times a function been called and the time they took to finish the caching process for 60 games stored in a local FTP server.
THEN | AFTER | DIFFERENCE | |
---|---|---|---|
Function calls | 154770 calls | 71114 calls | ~46% |
Time | 588 ms | 197 ms | ~35% |
Time complexity | O(n^3) | O(n) |
Older implementation (v4)
154770 function calls (143511 primitive calls) in 1.588 seconds
ncalls tottime percall cumtime percall (function)
1 0.006 0.006 1.476 1.476 (start_cache)
1503 0.004 0.000 0.855 0.001 (getresp)
1503 0.003 0.000 0.851 0.001 (getmultiline)
3483 0.019 0.000 0.849 0.000 {method 'readline' of '_io.TextIOWrapper' objects}
1694 0.009 0.000 0.849 0.001 (getline)
1852 0.005 0.000 0.820 0.000 (readinto)
1852 0.812 0.000 0.812 0.000 {method 'recv_into' of '_socket.socket' objects}
327 0.001 0.000 0.750 0.002 (transfercmd)
327 0.003 0.000 0.749 0.002 (ntransfercmd)
847 0.002 0.000 0.641 0.001 (sendcmd)
189 0.008 0.000 0.580 0.003 (retrlines)
187 0.002 0.000 0.575 0.003 (get_server_directories)
138 0.002 0.000 0.563 0.004 (download_data_from_server)
138 0.005 0.000 0.493 0.004 (retrbinary)
1 0.001 0.001 0.433 0.433 (filter_game_ids)
654 0.001 0.000 0.236 0.000 (voidresp)
327 0.001 0.000 0.228 0.001 (voidcmd)
327 0.002 0.000 0.219 0.001 (makepasv)
329 0.003 0.000 0.207 0.001 (create_connection)
Current implementation v5
71114 function calls (68944 primitive calls) in 1.197 seconds
ncalls tottime percall cumtime percall (function)
1 0.003 0.003 1.196 1.196 (start_cache)
1260 0.003 0.000 0.703 0.001 (getresp)
1260 0.002 0.000 0.700 0.001 (getmultiline)
3239 0.017 0.000 0.699 0.000 {method 'readline' of '_io.TextIOWrapper' objects}
1450 0.008 0.000 0.697 0.000 (getline)
1610 0.005 0.000 0.675 0.000 (readinto)
1610 0.667 0.000 0.667 0.000 {method 'recv_into' of '_socket.socket' objects}
267 0.001 0.000 0.626 0.002 (transfercmd)
267 0.003 0.000 0.625 0.002 (ntransfercmd)
189 0.008 0.000 0.575 0.003 (retrlines)
187 0.002 0.000 0.570 0.003 (get_server_directories)
725 0.002 0.000 0.529 0.001 (sendcmd)
1 0.001 0.001 0.440 0.440 (filter_game_ids)
78 0.001 0.000 0.381 0.005 (download_data_from_server)
78 0.004 0.000 0.343 0.004 (retrbinary)
534 0.001 0.000 0.193 0.000 (voidresp)
267 0.001 0.000 0.187 0.001 (voidcmd)
267 0.002 0.000 0.179 0.001 (makepasv)
268 0.003 0.000 0.178 0.001 (create_connection)
We can already see the difference in the number of function calls. The new implementation has fewer function calls, less runtime, time complexity, and much efficient. However, some games aren't in the DB such homebrews
& system apps
those will collect the information from the PS4 using the first method. Although its a bit complicated and irrelevant, I'm working on refactoring and reimplement it entirely using new techniques and data structures.
Note: the runtime is in (ms) and might seem it's no big deal, because it was logged for 60 games and from a local host, not directly from PS4 FTP. The larger the number of games the bigger the difference.
- Navigate to Game folder via the FTP
- Validate the image selected by user (most importantly the size >= 512)
- Count the number of icons required (Both
DDS
&PNG
) - Duplicate the user selected image
- Backup the image before uploading
- Upload and overwrite all to PS4
The following performance recorded by Perf_counter Python 3.11
.
The following process heavily depend on CONNECTION SPEED
& IMAGE SIZE
local FTP | PS4 FTP | |
---|---|---|
1 | 0.2115 | 1.1958 |
2 | 0.3873 | 0.7005 |
AVG(seconds) | 0.2994 | 0.9482 |
local FTP | PS4 FTP | |
---|---|---|
1 | - | 7.8837 |
2 | - | 6.4363 |
AVG(seconds) | - | 7.1600 |