zoukankan      html  css  js  c++  java
  • 在C中测试函数运行时间

    #include <stdio.h>
    #include <time.h>
    #include <math.h>
    
    clock_t start, stop;    //clock_t为clock()返回的变量类型
    double duration;        //记录被测函数运行时间,以秒为单位
    
    int main(int argc, char **argv)
    {
        /* 不再测试范围内的准备工作写在clock()调用之前 */
    
        //开始计时
        start = clock();
        //被测量的函数
    
        //停止计时
        stop = clock();
        //计算运行时间
        duration = ((double)(stop - start)) / CLOCKS_PER_SEC;
    
        /* 其他不在测试范围的处理写在后面, 例如输出duration的值 */
        printf("Running time: %6.2es.
    ", duration);
        return 0;
    }
  • 相关阅读:
    dubbo springcloud区别
    rpc
    centos7 安装docker
    vibox安装
    知识点
    spring cloud
    微服务设计原则
    工具类
    xss--知识点
    java基础--注解
  • 原文地址:https://www.cnblogs.com/Will-zyq/p/11329307.html
Copyright © 2011-2022 走看看