Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public OnRconCommand(cmd[])
- {
- if (!strcmp(cmd, "test", true)) {
- const
- num_iters = 1000000;
- new
- szBuffer[512],
- tick_count;
- tick_count = GetTickCount();
- for (new iter; iter < num_iters; iter++) {
- szBuffer = "#0 #0 #0";
- for (new pos = -1, num_names; (pos = strfind(szBuffer, "#", false, pos + 1)) != -1 && num_names < 4;) {
- new
- str[45],
- num_digits,
- _id = INVALID_PLAYER_ID
- ;
- for (new i = pos + 1; i < sizeof(szBuffer) && '0' <= szBuffer[i] <= '9' && num_digits < 3; i++) {
- str[num_digits++] = szBuffer[i];
- _id = strval(str);
- }
- if (_id != INVALID_PLAYER_ID && IsPlayerConnected(_id)) {
- format(str, sizeof(str), "{%06x}%s{ffffff}", GetPlayerColor(_id) >>> 8, playerName[_id]);
- strdel(szBuffer, pos, pos + num_digits + 1);
- strins(szBuffer, str, pos);
- num_names++;
- }
- }
- }
- printf("for | time: %d ticks", GetTickCount()-tick_count);
- tick_count = GetTickCount();
- for (new iter; iter < num_iters; iter++) {
- szBuffer = "#0 #0 #0";
- new
- pos = -1,
- str[50],
- num_names,
- num_digits,
- _id
- ;
- while ((pos = strfind(szBuffer, "#", false, pos + 1)) != -1 && num_names < 4) {
- num_digits = 0;
- _id = INVALID_PLAYER_ID;
- for (new i = pos + 1; i < sizeof(szBuffer) && '0' <= szBuffer[i] <= '9' && num_digits < 3; i++) {
- str[num_digits++] = szBuffer[i];
- _id = strval(str);
- }
- if (_id != INVALID_PLAYER_ID && IsPlayerConnected(_id)) {
- format(str, sizeof(str), "{%06x}%s{ffffff}", GetPlayerColor(_id) >>> 8, playerName[_id]);
- strdel(szBuffer, pos, pos + num_digits + 1);
- strins(szBuffer, str, pos);
- num_names++;
- }
- }
- }
- printf("while | time: %d ticks", GetTickCount()-tick_count);
- return 1;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement