Linux.com

Amandesi

Amandesi

  • Linux.com Member
  • Posts: 1
  • Member Since: 25 Sep 09
  • Last Logged In: 19 Sep 10

Latest Posts

Posted by
Topic
Post Preview
Posted
  • Amandesi
    How to convert TSC cpu cycles into seconds ?
    main() { unsigned long long tsc_start, tsc_end; tsc_start = get_tsc(); // execute some code tsc_end = get_tsc(); printf("Total time for execution %llu cpu cycles", tsc_end - tsc_start); printf("Total time in seconds ") ; // How to compute this ? } static unsigned long long get_tsc() { unsigned long long tsc; asm volatile ("rdtsc" : "=A" (tsc)); return tsc; }
    Link to this post 20 Sep 10

    main()
    {
    unsigned long long tsc_start, tsc_end;
    tsc_start = get_tsc();
    // execute some code

    tsc_end = get_tsc();
    printf("Total time for execution %llu cpu cycles", tsc_end - tsc_start);
    printf("Total time in seconds ") ; // How to compute this ?
    }

    static unsigned long long get_tsc()
    {
    unsigned long long tsc;
    asm volatile ("rdtsc" : "=A" (tsc));
    return tsc;
    }

Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board