new BigStr[2000];
for(new i; i < MAX_PLAYERS; i++){
format(BigStr,sizeof(BigStr),"%s\t%s",BigStr,PlayerName[i]);
}
new BigStr[2000],
MiniStr[112];
for(new i; i < MAX_PLAYERS; i++){
format(MiniStr,sizeof(MiniStr),"\t%s",PlayerName[i]);
strcat(BigStr,MiniStr);
}
new BigStr[2048];
for(new i; i < MAX_PLAYERS; i++)
{
strcat(BigStr,"\t");
strcat(BigStr,PlayerName[i]);
}
В данном случае быстрее было бы:
pawn Код:
|
const ITER_COUNT = 100;
new BigStr[2000], MiniStr[112], pos, i;
new tick;
tick = GetTickCount();
for (new j = 0; j < ITER_COUNT; j++) {
for(i = 0; i < MAX_PLAYERS; i++){
format(BigStr,sizeof(BigStr),"%s\t%s",BigStr,PlayerName[i]);
}
}
printf("format: %d", GetTickCount() - tick);
tick = GetTickCount();
for (new j = 0; j < ITER_COUNT; j++) {
for(i = 0; i < MAX_PLAYERS; i++){
format(MiniStr,sizeof(MiniStr),"\t%s",PlayerName[i]);
strcat(BigStr,MiniStr);
}
}
printf("format+strcat: %d", GetTickCount() - tick);
tick = GetTickCount();
for (new j = 0; j < ITER_COUNT; j++) {
for(i = 0; i < MAX_PLAYERS; i++){
strcat(BigStr, "\t");
strcat(BigStr, PlayerName[i]);
}
}
printf("strcat: %d", GetTickCount() - tick);
tick = GetTickCount();
for (new j = 0; j < ITER_COUNT; j++) {
pos = 0;
for(i = 0; i < MAX_PLAYERS; i++){
memcpy(BigStr, "\t", pos * 4, MAX_PLAYER_NAME * 4, sizeof(BigStr));
pos += 1;
memcpy(BigStr, PlayerName[i], pos * 4, MAX_PLAYER_NAME * 4, sizeof(BigStr));
pos += strlen(PlayerName[i]);
}
}
printf("memcpy: %d", GetTickCount() - tick);
/*
tick = GetTickCount();
for (new j = 0; j < ITER_COUNT; j++) {
pos = 0;
for(i = 0; i < MAX_PLAYERS; i++){
strins(BigStr, "\t", pos);
pos += 1;
strins(BigStr, PlayerName[i], pos);
pos += strlen(PlayerName[i]);
}
}
printf("strins: %d", GetTickCount() - tick);*/
format: 640
format+strcat: 146
strcat: 211
memcpy: 69
format: 608
format+strcat: 147
strcat: 212
memcpy: 69
stock _strcat(dest[], const src[], &pos, size = sizeof(dest))
{
new
i = pos,
j;
while (i < size && src[j] != '\0') {
dest[i++] = src[j++];
}
pos += j;
}
tick = GetTickCount();
for (new j = 0; j < ITER_COUNT; j++) {
pos = 0;
for(i = 0; i < MAX_PLAYERS; i++){
_strcat(BigStr, "\t", pos);
_strcat(BigStr, PlayerName[i], pos);
}
}
printf("_strcat: %d", GetTickCount() - tick);
format: 612
format+strcat: 148
strcat: 213
memcpy: 76
_strcat: 76
new TickCount = GetTickCount();
for(new p; p < 500; p++){
minidialog ="";
strcat(minidialog, "{------}\t\t----| ----------- ----: |----\n");
strcat(minidialog, "----------- ------- ------- ---- - ----\n");
strcat(minidialog, "\t----- --- --------- -----\n");
strcat(minidialog, "\t\t------ ------ \"{------}Alt / 2{------}\"\n");
strcat(minidialog, "\t\t------ ------ \"{------}Y{------}\"\n");
strcat(minidialog, "\t\t----| -------------: |----\n");
strcat(minidialog, "\"{------}/ (3-10){------}\"\t\t------\n");
strcat(minidialog, "\"{------}/f{------}\"\t\t\t----------- ---- [--------]\n");
strcat(minidialog, "\"{------}/ (1-2){------}\"\t\t-------- -- ---- ------\n");
strcat(minidialog, "\"{------}/ (1-16){------}\"\t\t-------- -- ----- ------\n");
strcat(minidialog, "\"{------}/ (0-99){------}\"\t\t------- ----------- ---\n");
strcat(minidialog, "\"{------}/ (0-1000){------}\"\t\t------- --- -------\n");
strcat(minidialog, "\"{------}/{------}\"\t\t\t----- ----------- ---\n");
strcat(minidialog, "\"{------}/{------}\"\t\t------- -------- [-- ------ ---- --------]\n");
strcat(minidialog, "\"{------}/{------}\"\t\t\t------------\n");
strcat(minidialog, "\"{------}/{------}\"\t\t\t-----: ------, ------- VIP, ------\n");
strcat(minidialog, "\"{------}/{------}\"\t\t------ ---------------\n");
strcat(minidialog, "\"{------}/{------}\"\t\t\t"TEXT_CLAN_11" - VIP\n");
strcat(minidialog, "\"{------}/{------}\"\t\t------- ----\n");
strcat(minidialog, "\"{------}/{------}\"\t\t\t------ -- -------\n");
strcat(minidialog, "\"{------}/{------}\"\t\t\t------ -- ----\n");
strcat(minidialog, "\"{------}/{------}\"\t\t------- -------\n");
strcat(minidialog, "\"{------}/{------}\"\t\t-------- ---- ---\n");
strcat(minidialog, "\"{------}/{------}\"\t\t----- Moovie [----- --- ------ -----]\n");
strcat(minidialog, "\"{------}/{------}\"\t\t---------- --------\n");
strcat(minidialog, "\"{------}/ (ID){------}\"\t\t------- -------- -- ----\n");
strcat(minidialog, "\"{------}/ (text){------}\"\t\t------ ----------\n");
strcat(minidialog, "\"{------}/{------}\"\t\t-------- ------\n");
strcat(minidialog, "\"{------}/{------}\"\t\t------ ---- ----------- ---");
}
printf("1] %d",GetTickCount()-TickCount);
TickCount = GetTickCount();
new pos;
for(new p; p < 500; p++){
pos = 0;
_strcat(minidialog, "{------}\t\t----| ----------- ----: |----\n",pos);
_strcat(minidialog, "----------- ------- ------- ---- - ----\n",pos);
_strcat(minidialog, "\t----- --- --------- -----\n",pos);
_strcat(minidialog, "\t\t------ ------ \"{------}Alt / 2{------}\"\n",pos);
_strcat(minidialog, "\t\t------ ------ \"{------}Y{------}\"\n",pos);
_strcat(minidialog, "\t\t----| -------------: |----\n",pos);
_strcat(minidialog, "\"{------}/ (3-10){------}\"\t\t------\n",pos);
_strcat(minidialog, "\"{------}/f{------}\"\t\t\t----------- ---- [--------]\n",pos);
_strcat(minidialog, "\"{------}/ (1-2){------}\"\t\t-------- -- ---- ------\n",pos);
_strcat(minidialog, "\"{------}/ (1-16){------}\"\t\t-------- -- ----- ------\n",pos);
_strcat(minidialog, "\"{------}/ (0-99){------}\"\t\t------- ----------- ---\n",pos);
_strcat(minidialog, "\"{------}/ (0-1000){------}\"\t\t------- --- -------\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t\t----- ----------- ---\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t------- -------- [-- ------ ---- --------]\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t\t------------\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t\t-----: ------, ------- VIP, ------\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t------ ---------------\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t\t"TEXT_CLAN_11" - VIP\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t------- ----\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t\t------ -- -------\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t\t------ -- ----\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t------- -------\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t-------- ---- ---\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t----- Moovie [----- --- ------ -----]\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t---------- --------\n",pos);
_strcat(minidialog, "\"{------}/ (ID){------}\"\t\t------- -------- -- ----\n",pos);
_strcat(minidialog, "\"{------}/ (text){------}\"\t\t------ ----------\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t-------- ------\n",pos);
_strcat(minidialog, "\"{------}/{------}\"\t\t------ ---- ----------- ---",pos);
}
printf("2] %d",GetTickCount()-TickCount);
[13:48:40] 1] 21 [13:48:40] 2] 612 [13:52:13] 1] 19 [13:52:14] 2] 512 [13:52:18] 1] 20 [13:52:18] 2] 503
Мб не так понял чтото?)
Код:
[13:48:40] 1] 21 [13:48:40] 2] 612 [13:52:13] 1] 19 [13:52:14] 2] 512 [13:52:18] 1] 20 [13:52:18] 2] 503 |