015
16.11.2004, 14:11 Uhr
FloSoft
Medialer Over-Flow (Administrator)
|
aua, da merkt man das das bitweise schreiben lahmt:
test1 war mein code:
C++: |
#include <stdio.h> #include <memory.h>
int main(void) { FILE *f = fopen("test1.out","wb"); if(f) { char *einmb = new char[10485760]; // sollte gehen = 10MB-Teile memset(einmb,0,10485760); // 0 setzen for(int x = 0; x < 10; x++) fwrite(einmb,1,10485760,f); delete[] einmb; // 10mb-speicher wieder freigeben fclose(f); } return 0; }
|
test2 war virtuals code:
C++: |
#include <fstream> int main() { std::ofstream grosse_datei("test2.out"); for(int i=0; i<1024*1024*100; ++i) grosse_datei<<'x'; grosse_datei.close(); }
|
Code: |
# time ./test1 real 0m4.133s user 0m0.000s sys 0m2.600s
|
Code: |
# time ./test2 real 1m26.715s user 1m23.840s sys 0m2.870s
|
-- class God : public ChuckNorris { }; |