~ubuntu-branches/ubuntu/utopic/linuxlogo/utopic

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Reichle-Schmehl
  • Date: 2010-03-10 11:25:34 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20100310112534-sbweh2jsk041w73u
Tags: 5.10-1
* New upstream release.
* Drop patches/01-s390x.patch and patches/02-sh.patch
  (both were pplied upstream)
* remove quilt, as we don't have any more patches
* Add $remote_fs to Required-Start and Required-Stop of the init scripts
  LSB header
* Bump standards version (no changes needed)

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
 
  long i;
23
 
  for (i = loops; i >= 0 ; i--)
24
 
    ;
25
 
}
26
 
 
27
 
float external_bogomips() {
28
 
   
29
 
  unsigned long loops_per_sec = 1;
30
 
  unsigned long ticks;
31
 
  
32
 
  while ((loops_per_sec <<= 1)) {
33
 
    ticks = clock();
34
 
    delay(loops_per_sec);
35
 
    ticks = clock() - ticks;
36
 
    if (ticks >= CLOCKS_PER_SEC) {
37
 
      loops_per_sec = (loops_per_sec / ticks) * CLOCKS_PER_SEC;
38
 
      return (float)loops_per_sec/500000;
39
 
 
40
 
    }
41
 
  }
42
 
  return -1;
43
 
}
44
 
 
45
 
#endif