Skip to content
João Medeiros edited this page Apr 8, 2023 · 47 revisions

Performance Measure

SYNOPSIS
       #include <sys/time.h>

       int gettimeofday(struct timeval *tv, struct timezone *tz);
struct timeval
{
    time_t      tv_sec;     /* seconds */
    suseconds_t tv_usec;    /* microseconds */
};
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>

int main(int argc, char **argv)
{
    struct timeval a, b;
    unsigned int t;

    gettimeofday(&b, NULL);
    sleep(1);
    gettimeofday(&a, NULL);

    t = (a.tv_sec * 1e6 + a.tv_usec) - (b.tv_sec * 1e6 + b.tv_usec);

    printf("%u\n", t);

    return 0;
}
int search(int *v, unsigned int n, int k)
{
    while (n-- > 0)
    {
        if (v[n] == k)
            return n;
    }
    return -1;
}

int main(int argc, char **argv)
{
    for ()
    return 0;
}

Clone this wiki locally