~ubuntu-branches/ubuntu/trusty/linuxlogo/trusty

« back to all changes in this revision

Viewing changes to libsysinfo-0.1.0/all/bogomips.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2008-06-20 09:19:00 UTC
  • mfrom: (4.1.2 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080620091900-4xzuv7c7ntxvs7wt
Tags: 5.03-4
* Adding patch to fix FTBFS on s390x.
* Updating to standards 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef linux
2
 
/*
3
 
 *                Standalone BogoMips program
4
 
 *
5
 
 * Based on code Linux kernel code in init/main.c and
6
 
 * include/linux/delay.h
7
 
 *
8
 
 * For more information on interpreting the results, see the BogoMIPS
9
 
 * Mini-HOWTO document.
10
 
 *
11
 
 * version: 1.3 
12
 
 *  author: Jeff Tranter (Jeff_Tranter@Mitel.COM)
13
 
 *
14
 
 * Modified for inclusion with Linux_Logo -- Vince Weaver
15
 
 */
16
 
 
17
 
#include <stdio.h>
18
 
#include <time.h>
19
 
 
20
 
/* portable version */
21
 
static void delay(int loops)
22
 
{
23
 
  long i;
24
 
  for (i = loops; i >= 0 ; i--)
25
 
    ;
26
 
}
27
 
 
28
 
float external_bogomips() {
29
 
   
30
 
  unsigned long loops_per_sec = 1;
31
 
  unsigned long ticks;
32
 
  
33
 
  while ((loops_per_sec <<= 1)) {
34
 
    ticks = clock();
35
 
    delay(loops_per_sec);
36
 
    ticks = clock() - ticks;
37
 
    if (ticks >= CLOCKS_PER_SEC) {
38
 
      loops_per_sec = (loops_per_sec / ticks) * CLOCKS_PER_SEC;
39
 
      return (float)loops_per_sec/500000;
40
 
 
41
 
    }
42
 
  }
43
 
  return -1;
44
 
}
45
 
 
46
 
#endif