Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Performance test.

  • Loading branch information...
commit e29be589e895b8bff5a483590b7e1cae690b1701 1 parent 6595102
Keith Rarick authored
Showing with 74 additions and 0 deletions.
  1. +1 −0  .gitignore
  2. +2 −0  Makefile
  3. +71 −0 perf.c
View
1  .gitignore
@@ -1,6 +1,7 @@
.*.d
*.o
beanstalkd
+perf
gmon.out
tags
tests/cutcheck*
View
2  Makefile
@@ -25,6 +25,8 @@ check: tests/cutcheck $(objects)
$(program): $(objects) $(program).o
+perf: $(objects) perf.o
+
check: export CFLAGS := $(CFLAGS) -D__LINUX__
tests/cutgen: tests/cutgen.c
View
71 perf.c
@@ -0,0 +1,71 @@
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <sys/time.h>
+
+#include "tube.h"
+#include "job.h"
+#include "util.h"
+#include "pq.h"
+
+static tube default_tube;
+
+static void
+elapsed(struct timeval *t0, struct timeval *t1)
+{
+ printf("elapsed %zdms\n",
+ (1000 * (t1->tv_sec - t0->tv_sec)) +
+ (t1->tv_usec / 1000) - (t0->tv_usec / 1000));
+}
+
+int
+main(int argc, char **argv)
+{
+ int i;
+ job j;
+ struct timeval t0, t1, t2, t3, t4;
+
+ progname = argv[0];
+
+ job_init();
+ TUBE_ASSIGN(default_tube, make_tube("default"));
+
+ printf("inserting 2M ");
+ fflush(stdout);
+ gettimeofday(&t0, NULL);
+ for (i = 0; i < 2000000; i++) {
+ j = make_job(1, 0, 1, 0, default_tube);
+ }
+ gettimeofday(&t1, NULL);
+ elapsed(&t0, &t1);
+
+ printf("removing 200K ");
+ fflush(stdout);
+ for (i = 0; i < 200000; i++) {
+ j = job_find(i);
+ if (j) job_free(j);
+ }
+ gettimeofday(&t2, NULL);
+ elapsed(&t1, &t2);
+
+ printf("inserting 2M ");
+ fflush(stdout);
+ for (i = 0; i < 2000000; i++) {
+ j = make_job(1, 0, 1, 0, default_tube);
+ }
+ gettimeofday(&t3, NULL);
+ elapsed(&t2, &t3);
+
+ printf("removing 200K ");
+ fflush(stdout);
+ for (i = 0; i < 200000; i++) {
+ j = job_find(i + 2000000);
+ if (j) job_free(j);
+ }
+ gettimeofday(&t4, NULL);
+ elapsed(&t3, &t4);
+
+ printf("total ");
+ elapsed(&t0, &t4);
+ return 0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.