How to calculate MIPS for an algorithm for ARM processor

前端 未结 7 839
抹茶落季
抹茶落季 2021-02-01 10:23

I have been asked recently to produced the MIPS (million of instructions per second) for an algorithm we have developed. The algorithm is exposed by a set of C-style functions.

7条回答
  •  旧巷少年郎
    2021-02-01 10:46

    MIPS is generally used to measure the capability of a processor.

    Algorithms usually take either:

    1. a certain amount of time (when running on a certain processor)
    2. a certain number of instructions (depending on the architecture)

    Describing an algorithm in terms of instructions per second would seem like a strange measure, but of course I don't know what your algorithm does.

    To come up with a meaningful measure, I would suggest that you set up a test which allows you to measure the average time taken for your algorithm to complete. Number of assembly instructions would be a reasonable measure, but it can be difficult to count them! Your best bet is something like this (pseudo-code):

    const num_trials = 1000000
    start_time = timer()
    for (i = 1 to num_trials)
    {
        runAlgorithm(randomData)
    }
    time_taken = timer() - start_time
    average_time = time_taken / num_trials
    

提交回复
热议问题