cheahjs / palworld-save-tools

Tools for converting Palworld .sav files to JSON and back
MIT License
766 stars 64 forks source link

feat: increase performance up to 10x on exists string to uuid, 2x for new. #145

Closed magicbear closed 4 months ago

magicbear commented 4 months ago

def perf_new(): t1 = time.time() for i in range(10000000): s=str(UUID(b'\xbc\x99\xfe\xf6{\x0bLO\x8en\xe8\xb4\x1aC;5')) print(1000*(time.time()-t1))

def perf_exists(): t1 = time.time() uuids = UUID(b'\xbc\x99\xfe\xf6{\x0bLO\x8en\xe8\xb4\x1aC;5') for i in range(10000000): s=str(uuids) print(1000*(time.time()-t1))

perf_exists() Old -> 2681.8525791168213 New -> 277.8770923614502

perf_new() Old -> 11315.203666687012 New -> 6226.833820343018

increase performance up to 10x on exists string to uuid, 2x for new. reduce some performance for hash, but can be use just string to match in dict, just hash as UUID string