~ubuntu-branches/ubuntu/natty/nodejs/natty

« back to all changes in this revision

Viewing changes to benchmark/io.c

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard, Jérémy Lal, Jonas Smedegaard
  • Date: 2011-01-21 21:00:24 UTC
  • mfrom: (1.1.10 upstream)
  • mto: (7.1.7 sid)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: james.westby@ubuntu.com-20110121210024-hyhy73i8hu7nzzrg
Tags: 0.2.6-1
[ Jérémy Lal ]
* New upstream release.
* nodejs is an alternative to js. (Closes: #597572)
* Use upstream binary names for node and node-waf,
  conflicts with node package. (Closes: #597571)
* Global modules search paths :
  /usr/local/lib/nodejs
  /usr/lib/nodejs
  Custom paths can be set through NODE_PATH.
  The reason is to support future npm package, giving higher
  priority to modules installed by npm as root.
* Repackage using CDBS.  Enable regression testing.
* Add a note about importing upstream tarball in README.source.
* Update TODO

[ Jonas Smedegaard ]
* Add myself as uploader.
* Limit watch file to stable releases.
* Enable CDBS build-dependency autoresolving.
* Tighten build-dependency on cdbs to versions properly supporting
  debhelper compat level 7.
* Tighten build-dependency on debhelper to versions fully supporting
  compat level 7.
* Build-depend on dh-buildinfo to include buildinfo hints with binary
  packages for easier troubleshooting.
* Build-depend on curl: Needed for regression tests (testing on
  loopback, so should be Policy compliant).
* Newline-delimit package relations for improved readability.
* Add patch 2001 to skip TTY-needing regression test.

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
#include <unistd.h>
6
6
#include <string.h>
7
7
#include <fcntl.h>
8
 
#include <time.h>
 
8
#include <sys/time.h>
 
9
#include <assert.h>
9
10
#include <stdlib.h>
10
11
#include <stdio.h>
11
12
 
12
13
int tsize = 1000 * 1048576;
13
14
const char *path = "/tmp/wt.dat";
14
15
 
 
16
int c = 0;
15
17
 
16
18
char* bufit(size_t l)
17
19
{
24
26
{
25
27
  int i;
26
28
  char *buf = bufit(bsize);
27
 
  clock_t start, end;
 
29
  struct timeval start, end;
28
30
  double elapsed;
29
31
  double mbps;
30
32
 
34
36
    exit(254);
35
37
  }
36
38
 
37
 
  start = clock();
 
39
  assert(0 ==  gettimeofday(&start, NULL));
38
40
  for (i = 0; i < size; i += bsize) {
39
41
    int rv = write(fd, buf, bsize);
 
42
    if (c++ % 2000 == 0) fprintf(stderr, ".");
40
43
    if (rv < 0) {
41
44
      perror("write failed");
42
45
      exit(254);
48
51
  fsync(fd);
49
52
#endif
50
53
  close(fd);
51
 
  end = clock();
52
 
  elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;
 
54
  assert(0 == gettimeofday(&end, NULL));
 
55
  elapsed = (end.tv_sec - start.tv_sec) + ((double)(end.tv_usec - start.tv_usec))/100000.;
53
56
  mbps = ((tsize/elapsed)) / 1048576;
54
 
  fprintf(stderr, "Wrote %d bytes in %03fs using %d byte buffers: %03fmB/s\n", size, elapsed, bsize, mbps);
 
57
  fprintf(stderr, "\nWrote %d bytes in %03fs using %ld byte buffers: %03fmB/s\n", size, elapsed, bsize, mbps);
55
58
 
56
59
  free(buf);
57
60
}
60
63
{
61
64
  int i;
62
65
  char *buf = bufit(bsize);
63
 
  clock_t start, end;
 
66
  struct timeval start, end;
64
67
  double elapsed;
65
68
  double mbps;
66
69
 
70
73
    exit(254);
71
74
  }
72
75
 
73
 
  start = clock();
 
76
  assert(0 == gettimeofday(&start, NULL));
74
77
  for (i = 0; i < size; i += bsize) {
75
78
    int rv = read(fd, buf, bsize);
76
79
    if (rv < 0) {
79
82
    }
80
83
  }
81
84
  close(fd);
82
 
  end = clock();
83
 
  elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;
 
85
  assert(0 == gettimeofday(&end, NULL));
 
86
  elapsed = (end.tv_sec - start.tv_sec) + ((double)(end.tv_usec - start.tv_usec))/100000.;
84
87
  mbps = ((tsize/elapsed)) / 1048576;
85
 
  fprintf(stderr, "Read %d bytes in %03fs using %d byte buffers: %03fmB/s\n", size, elapsed, bsize, mbps);
 
88
  fprintf(stderr, "Read %d bytes in %03fs using %ld byte buffers: %03fmB/s\n", size, elapsed, bsize, mbps);
86
89
 
87
90
  free(buf);
88
91
}