Click here to Skip to main content
16,013,516 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Release version crashing Pin
Matt Newman26-Aug-03 17:54
Matt Newman26-Aug-03 17:54 
GeneralRe: Release version crashing Pin
act_x26-Aug-03 18:05
act_x26-Aug-03 18:05 
GeneralRe: Release version crashing Pin
ZoogieZork26-Aug-03 18:09
ZoogieZork26-Aug-03 18:09 
GeneralRe: Release version crashing Pin
Abin26-Aug-03 18:13
Abin26-Aug-03 18:13 
GeneralRe: Release version crashing Pin
act_x26-Aug-03 18:42
act_x26-Aug-03 18:42 
GeneralRe: Release version crashing Pin
Abin26-Aug-03 19:04
Abin26-Aug-03 19:04 
GeneralClasses already exist Pin
phaedrus26-Aug-03 17:17
phaedrus26-Aug-03 17:17 
Questionmemory manager hate 1024 and 2048? Pin
novachen26-Aug-03 17:08
novachen26-Aug-03 17:08 
In fact, I can't believe the result myself. But from my simple test, i found the matrix with 1024 alike is much slowly in memory access than 1023 or 1025.
I dont know the real reason.

My test program is very simple. My aim is test the memory copy cost in a matrix.
There are three parameters to used, M for the size of matrix, N for the rows or columns try to copy, and Z is make the program run longer to get a stable result.

#include <stdio.h>
#include <time.h>
#include <memory.h>
#include <stdlib.h>

void main(int argc, char** argv)
{
int M,N,Z;
M = atoi(argv[1]);
N = atoi(argv[2]);
Z = atoi(argv[3]);

char *buf, *buf2;
buf = new char[M*M];
memset(buf, 1, M*M);
buf2 = new char[M*M];
memset(buf2, 2, M*M);

int i,j,k;

clock_t a = clock();

for (k=0; k<Z; k++)
memcpy(buf2, buf, N*M);

clock_t b = clock();

for (k=0; k<Z; k++)
{
for (i=0; i<M; i++)
memcpy(&buf2[i*M], &buf[i*M], N);
}

clock_t c = clock();
printf("cost1 %ld const2 %ld\n", b-a, c-b);
}

The result I got:
Z is always 100000
M N Cost1 Cost2
1023 3 47 6000
1024 3 62 22750
1025 3 47 6516
2047 3 110 28000
2048 3 94 57093
2049 3 94 45187

You can see the weird result, 1024, 2048 has the worst performance against the smaller or bigger number.
I always use the power of 2 as matrix's side, but the test show i am wrong.
But any guru can tell what's the exact reason inside?
AnswerRe: memory manager hate 1024 and 2048? Pin
igor196026-Aug-03 18:51
igor196026-Aug-03 18:51 
GeneralRe: memory manager hate 1024 and 2048? Pin
novachen26-Aug-03 19:43
novachen26-Aug-03 19:43 
GeneralRe: memory manager hate 1024 and 2048? Pin
igor196026-Aug-03 21:08
igor196026-Aug-03 21:08 
GeneralRe: memory manager hate 1024 and 2048? Pin
novachen26-Aug-03 21:47
novachen26-Aug-03 21:47 
GeneralEdit Box Pin
DanYELL26-Aug-03 16:17
DanYELL26-Aug-03 16:17 
GeneralRe: Edit Box Pin
Neville Franks26-Aug-03 16:41
Neville Franks26-Aug-03 16:41 
Generalcome into possession of the operating system Pin
Hellin26-Aug-03 15:58
Hellin26-Aug-03 15:58 
GeneralRe: come into possession of the operating system Pin
Christian Graus26-Aug-03 16:16
protectorChristian Graus26-Aug-03 16:16 
GeneralRe: come into possession of the operating system Pin
Anonymous26-Aug-03 16:23
Anonymous26-Aug-03 16:23 
GeneralRe: come into possession of the operating system Pin
Christian Graus26-Aug-03 16:23
protectorChristian Graus26-Aug-03 16:23 
GeneralRe: come into possession of the operating system Pin
Anonymous26-Aug-03 16:39
Anonymous26-Aug-03 16:39 
GeneralRe: come into possession of the operating system Pin
Christian Graus26-Aug-03 16:40
protectorChristian Graus26-Aug-03 16:40 
GeneralRe: come into possession of the operating system Pin
Anonymous26-Aug-03 16:56
Anonymous26-Aug-03 16:56 
GeneralRe: come into possession of the operating system Pin
Christian Graus26-Aug-03 16:57
protectorChristian Graus26-Aug-03 16:57 
GeneralRe: come into possession of the operating system Pin
Anonymous26-Aug-03 17:07
Anonymous26-Aug-03 17:07 
GeneralRe: come into possession of the operating system Pin
Christian Graus26-Aug-03 17:09
protectorChristian Graus26-Aug-03 17:09 
GeneralRe: come into possession of the operating system Pin
Abin26-Aug-03 17:12
Abin26-Aug-03 17:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.