Calculating time of execution with time() function

前端 未结 5 1417
盖世英雄少女心
盖世英雄少女心 2020-12-07 06:12

I was given the following HomeWork assignment,

Write a program to test on your computer how long it takes to do nlogn, n2, n5, 2n, and n! additions

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-07 07:10

    Execute each calculation thousands of times, in a loop, so that you can overcome the low resolution of time and obtain meaningful results. Remember to divide by the number of iterations when reporting results.

    This is not particularly accurate but that probably does not matter for this assignment.

提交回复
热议问题