:でも、時間私はCプログラムによって取得され、どのくらい見たいので、私が書いたCで測定するとLinux
#include<stdio.h>
#include<stdlib.h>
#include"memory.h"
#include"memory_debug.h"
#include<sys/times.h>
#include<unistd.h>
int (*deallocate_ptr)(memContainer *,void*);
void (*merge_ptr)(node *);
void* (*allocate_ptr)(memContainer *,unsigned long size);
memContainer* (*init_ptr)(unsigned long);
diagStruct* (*diagnose_ptr)(memContainer *);
void (*finalize_ptr)(memContainer *);
void (*printNode_ptr)(node *n);
void (*printContainer_ptr)(memContainer *c);
void info(memContainer *c)
{
struct tms *t;
t=malloc(sizeof(struct tms));
times(t);
printf("user : %d\nsystem : %d\n %d",t->tms_utime,(int)t->tms_stime);
diagnose_ptr(c);
printf("\n");
return ;
}
を私は、この関数を呼び出すときに私は0ユーザ時間と0システム時刻を取得します私が書く場合:
for (i=0;i<100000;++i)
for (j=0;j<10;++j)
{}
info(c);
私は間違って何をしていますか?
あなたが実行 '時間a.out'、しても、その表示回数? – Douglas
私はあなたのプログラムが情報の後に出てから気にしないと思いますが、もしそうでなければ、メモリリークがあります。 – ShinTakezou
これは単なるスニペットです。時間はa.outです。 – Andna