alliedmodders / metamod-source

Metamod:Source - C++ Plugin Environment and Detour Library for the Source Engine
http://www.metamodsource.net/
Other
370 stars 84 forks source link

Replace fscanf with faster parsing #2 #152

Closed KaelaSavia closed 7 months ago

KaelaSavia commented 7 months ago

Credits to original pull https://github.com/alliedmodders/metamod-source/pull/127 @PeakKS

Introduces faster parsing to ModuleInMemory.

dvander commented 7 months ago

Do you have any benchmark data for this?

KaelaSavia commented 7 months ago

PR replaces fscanf with getline which is faster than fscanf.

Elapsed CPU Time (FSCANF) = '7.91713' sec. Elapsed CPU Time per Iteration (FSCANF, 500000) = '1.583425e-05' sec. Elapsed CPU Time (GETLINE) = '4.13407' sec. Elapsed CPU Time per Iteration (GETLINE, 500000) = '8.268138e-06' sec.

As per in-game performance, on stress test map with a lot of sdkhooked entities. Time goes from 1975 ms to 903 ms. (https://github.com/alliedmodders/sourcemod/issues/1935)