Thread: HTTP:X
View Single Post
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-14-2016 , 17:54   Re: HTTP:X
Reply With Quote #25

Quote:
Originally Posted by JusTGo View Post
well i guess it better to pass the index directly into the handler when downloading 2 or more files btw MAX_DOWNLOAD_SLOTS 10 does that mean the plugin can't download 32 files when players connect at the same time ?
It will que the files. It allows 10 simoultaneous downloads. As soon as one download is done and there are downloads left in the que they will be added automatically. Tomorrow I will test the time it takes to download 32 examples.



Edit:
It's done.
HTTPX_SetCustom(DownloadID, any:val)
any:HTTPX_GetCustom(DownloadID)

HTTP:X will update automatically, you don't need to download it manually.



I also tested the time it took to completely download a different number of files at the same time.
Don't run this yourself as I got banned doing it. Allthough I ran it using 1s delay between each run.
Code:
#include <amxmodx> #include <httpx> #define TimerStart()            tickcount() #define TimerMid(%0)            ( tickcount() - %0 ) #define TimerStop(%0)         ( %0 = tickcount() - %0 ) #define TimerDays(%0)         ( %0 / 86400000 ) #define TimerHours(%0)      ( %0 % 86400000 / 3600000 ) #define TimerMinutes(%0)        ( %0 % 3600000 / 60000 ) #define TimerSeconds(%0)        ( %0 % 60000 / 1000 ) #define TimerMilliseconds(%0)   ( %0 % 1000 ) new gNum, gCount, hTimer; public plugin_init() {     register_plugin("Time test", "1.0", "[ --{-@ ]");     set_task(10.0, "TestDownload"); } public TestDownload() {     gCount = 0;     gNum++;     new szURL[40];     hTimer = TimerStart();     for ( new i ; i < gNum ; i++ ) {         format(szURL, charsmax(szURL), "http://ip-api.com/json/%d.%d.%d.%d", random(256), random(256), random(256), random(256));         HTTPX_Download(szURL, _, "Complete");     } } public Complete(DownloadID, Error) {     if ( Error )         return;     if ( ++gCount != gNum )         return;     TimerStop(hTimer);     new szTimer[32];     TimerFormat(hTimer, szTimer, charsmax(szTimer), 2);     server_print("%-2.2d download%s: %s (%-4.4dms/download)", gNum, gNum == 1 ? " " : "s", szTimer, hTimer/gNum);     if ( gNum < 32 )         set_task(60.0, "TestDownload"); } stock TimerFormat(hTimer, output[], maxlen, mode = 1, bool:full = false) {     new len;         if ( full || TimerDays(hTimer) )         len = formatex(output, maxlen, mode == 1 ? "%02d:" : "%dd ", TimerDays(hTimer));     if ( full || ( len && mode == 1 ) || TimerHours(hTimer) )         len += formatex(output[len], maxlen - len, mode == 1 ? "%02d:" : "%dh ", TimerHours(hTimer));     if ( full || ( len && mode == 1 ) || TimerMinutes(hTimer) )         len += formatex(output[len], maxlen - len, mode == 1 ? "%02d:" : "%dm ", TimerMinutes(hTimer));             if ( full || ( len && mode == 1 ) || TimerSeconds(hTimer) )         len += formatex(output[len], maxlen - len, mode == 1 ? "%02d." : "%ds ", TimerSeconds(hTimer));     if ( full || ( len && mode == 1 ) || TimerMilliseconds(hTimer) )         len += formatex(output[len], maxlen - len, mode == 1 ? "%03d" : "%dms", TimerMilliseconds(hTimer)); }

Code:
1 download : 261ms (261ms/download)
2 downloads: 285ms (142ms/download)
3 downloads: 311ms (103ms/download)
4 downloads: 340ms (85ms/download)
5 downloads: 367ms (73ms/download)
6 downloads: 400ms (66ms/download)
7 downloads: 439ms (62ms/download)
8 downloads: 475ms (59ms/download)
9 downloads: 511ms (56ms/download)
10 downloads: 547ms (54ms/download)
11 downloads: 676ms (61ms/download)
12 downloads: 702ms (58ms/download)
13 downloads: 740ms (56ms/download)
14 downloads: 755ms (53ms/download)
15 downloads: 781ms (52ms/download)
16 downloads: 818ms (51ms/download)
At this point I was banned and the test ended.
As you can see from the data I managed to gather before getting banned the time per download decreased logarithmically.
When reaching the end of the maximum number of downloads (10) the que is activated for the 11th entry and the time per download gets a small bump but then settles down and passes the previous results.
It will probably continue to get more effective throughout. Theoretically the only bump should be at 10 downloads. After that the que will keep active at all times and shouldn't affect the time in a negative way anymore.
Without following the pattern too much, assuming it will stagnate at 50ms/download you're looking at 1.6s for 32 players.

Edit:
I ran a second test using my own HTTP server (about 2m away on a gigabit LAN) and the result was interesting.
For every download added ~10ms was added to the time. And after every tenth an extra 100ms was added. Most likely due to the que work.
This is more or less the time of the internal works of the plugin. The other factor being response time and connection speed to the server.
Code:
1  download : 209ms(~210) (209 ms/download) +~210
2  downloads: 220ms(~220) (110 ms/download) +~ 10
3  downloads: 228ms(~230) (76  ms/download) +~ 10
4  downloads: 240ms(~240) (60  ms/download) +~ 10
5  downloads: 250ms(~250) (50  ms/download) +~ 10
6  downloads: 261ms(~260) (43  ms/download) +~ 10
7  downloads: 269ms(~270) (38  ms/download) +~ 10
8  downloads: 280ms(~280) (35  ms/download) +~ 10
9  downloads: 290ms(~290) (32  ms/download) +~ 10
10 downloads: 299ms(~300) (29  ms/download) +~ 10
11 downloads: 409ms(~410) (37  ms/download) +~110
12 downloads: 418ms(~420) (34  ms/download) +~ 10
13 downloads: 429ms(~430) (33  ms/download) +~ 10
14 downloads: 440ms(~440) (31  ms/download) +~ 10
15 downloads: 449ms(~450) (29  ms/download) +~ 10
16 downloads: 459ms(~460) (28  ms/download) +~ 10
17 downloads: 469ms(~470) (27  ms/download) +~ 10
18 downloads: 478ms(~480) (26  ms/download) +~ 10
19 downloads: 488ms(~490) (25  ms/download) +~ 10
20 downloads: 499ms(~500) (24  ms/download) +~ 10
21 downloads: 609ms(~610) (29  ms/download) +~110
22 downloads: 619ms(~620) (28  ms/download) +~ 10
23 downloads: 629ms(~630) (27  ms/download) +~ 10
24 downloads: 639ms(~640) (26  ms/download) +~ 10
25 downloads: 648ms(~650) (25  ms/download) +~ 10
26 downloads: 658ms(~660) (25  ms/download) +~ 10
27 downloads: 670ms(~670) (24  ms/download) +~ 10
28 downloads: 679ms(~680) (24  ms/download) +~ 10
29 downloads: 689ms(~690) (23  ms/download) +~ 10
30 downloads: 699ms(~700) (23  ms/download) +~ 10
31 downloads: 809ms(~810) (26  ms/download) +~110
32 downloads: 818ms(~820) (25  ms/download) +~ 10
__________________

Last edited by Black Rose; 09-15-2016 at 16:04.
Black Rose is offline