cwbe coordinatez:
101
792011
2663954
2663960
2731249

ABSOLUT
KYBERIA
permissions
you: r,
system: public
net: yes

neurons

stats|by_visit|by_K
source
tiamat
commanders
polls

total descendants::
total children::0
show[ 2 | 3] flat


kedze vsade sa kazdy vytesuje zo std::string, spravil som si jeden rychly "benchmark", softwareovi teoretici ma mozu spindat, ze to nie je uplne reprezentativne, ale mne to stacilo... tu su vysledky... pre tych, ktorych to zaujima:

release>bm_cstr.exe
100000 additions in 20 msec (26904606, 26904626) -- 0.00020 per add
release>bm_stdstr.exe
100000 additions in 170 msec (26907120, 26907290) -- 0.00170 per add

testovaci program:

#define __STDSTRING

#include <string>
#include <stdio.h>
#include <windows.h>

using namespace std;

int main(int argc, char* argv[]) {
DWORD tick_begin, tick_end;
tick_begin = GetTickCount();

#ifdef __STDSTRING
string dest;
string src("test1");
for (int x = 0; x < 100000; x++) dest = src + "test2";
#else
char* dest = (char*)malloc(1024);
memset(dest, 0, 1024);
char* src = "test1";
for (int x = 0; x < 100000; x++) {
memset(dest, 0, 1024);
strcat(dest, (char*)&src);
strcat(dest, "test2");
}
free(dest);
#endif
tick_end = GetTickCount();

printf("100000 additions in %u msec (%u, %u) -- %.5f per add\n", tick_end - tick_begin,
tick_begin, tick_end, (tick_end - tick_begin) / 100000.0);

return (0);
}