免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1548 | 回复: 6
打印 上一主题 下一主题

[SCO UNIX] 测试时间函数,请大家帮忙试一下 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2004-02-13 11:47 |只看该作者 |倒序浏览
由于身边没有Tru64 UNIX的机器,所以下面的一段统计时间的函数麻烦各位有Tru64 UNIX平台的朋友帮我试一试,程序如下(文件名为time1.c):
#include <stdio.h>;
#include <time.h>;

void main ()
{
   double t0, t1;
   time_t u1,u2;
   int i,j,k,temp;

   time(&u1);
   t0 = clock();

   while(i<10000)
        {
           for(j=0;j<20000;j++)
           {
                  
                temp=0;
               
           }               
           i++;
        };
       
   t1 = clock();
   time(&u2);

   printf("CPU time = %7.2f \nUser Time = %d secs.\n\n",t1-t0,(int)(u2-u1));
}
使用cc time1.c
执行结果文件,看一看会不会有时间结果信息。
请把结果信息贴出来,谢谢!

论坛徽章:
0
2 [报告]
发表于 2004-02-19 13:18 |只看该作者

测试时间函数,请大家帮忙试一下

难道这么简单,举手之劳的事情大家都不愿意帮忙试一下吗?

论坛徽章:
0
3 [报告]
发表于 2004-02-19 13:55 |只看该作者

测试时间函数,请大家帮忙试一下

[quote]原帖由 "watertek"]难道这么简单,举手之劳的事情大家都不愿意帮忙试一下吗?[/quote 发表:


错误信息如下:
syntax error at line 2 : `newline or ;' unexpected

论坛徽章:
0
4 [报告]
发表于 2004-02-19 13:56 |只看该作者

测试时间函数,请大家帮忙试一下

执行报错如下:

cc: Error: time.c, line 1: Missing ";". (nosemi)
nclude <stdio.h>;
-------^
cc: Error: /usr/include/time.h, line 132: In this declaration, "size_t" appears)
extern size_t   strftime __((char *, size_t , const char *,const struct tm *));
-------^
cc: Error: /usr/include/sys/select.h, line 240: Ill-formed parameter type list.)
extern void  bzero __((void *, size_t));
-------------------^
cc: Error: /usr/include/sys/signalmisc.h, line 85: Missing type specifier or ty)
        size_t  ss_size;                /* size of stack - 0 if unknown */
--------^

论坛徽章:
0
5 [报告]
发表于 2004-02-19 14:40 |只看该作者

测试时间函数,请大家帮忙试一下

谢谢回复,想确认一下您的机器是Tru64 UNIX 4.0F版本,编译器是CC5.9版本的吗,有没有qq活着msn留下

论坛徽章:
0
6 [报告]
发表于 2004-02-19 14:43 |只看该作者

测试时间函数,请大家帮忙试一下

[quote]原帖由 "watertek"]谢谢回复,想确认一下您的机器是Tru64 UNIX 4.0F版本,编译器是CC5.9版本的吗,有没有qq活着msn留下 [/quote 发表:



tru64 5.1b
cc 的版本不太清楚,也不知道怎么看^_^

论坛徽章:
0
7 [报告]
发表于 2004-02-19 15:41 |只看该作者

测试时间函数,请大家帮忙试一下

#include <stdio.h>;
#include <time.h>;

void main ()
{
  double c0, c1;
  time_t u0, u1;
  int i, j, temp;
  time(&u0);
  c0 = clock();
  for(i=0; i<30000; i++)
  {
    for(j=0; j<30; j++)
    {
      printf(".";
    }
  }
  printf("\n";
  time(&u1);
  c1 = clock();
  printf("CPU time  = %.2f starting at %.2f and ending at %.2f\n" \
         "User time = %d secs starting at %d and ending at %d\n\n",
         (c1-c0), c0, c1, (int)(u1-u0), (int) u0, (int) u1);
}
再麻烦你帮我试一下,能够得到clock的统计吗,把结果贴出来
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP