aboutsummaryrefslogtreecommitdiff
path: root/benchmarks
diff options
context:
space:
mode:
Diffstat (limited to 'benchmarks')
-rw-r--r--benchmarks/ChangeLog16
-rw-r--r--benchmarks/Makefile26
-rw-r--r--benchmarks/forks.c63
3 files changed, 105 insertions, 0 deletions
diff --git a/benchmarks/ChangeLog b/benchmarks/ChangeLog
new file mode 100644
index 00000000..fb7b1a6f
--- /dev/null
+++ b/benchmarks/ChangeLog
@@ -0,0 +1,16 @@
+1999-10-01 Roland McGrath <roland@baalperazim.frob.com>
+
+ * forks.c: Add #include's to silence implicit decl warnings
+ (main): Use time_t and add a cast, to silence type warnings.
+
+1999-09-14 Thomas Bushnell, BSG <tb@mit.edu>
+
+ * forks.c (main): Count argc correctly.
+
+Wed Apr 12 11:25:25 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu>
+
+ * Makefile (OBJS): New var.
+
+Tue Apr 11 11:17:32 1995 Michael I Bushnell <mib@duality.gnu.ai.mit.edu>
+
+ * Makefile: Rewrote in accordance with new scheme.
diff --git a/benchmarks/Makefile b/benchmarks/Makefile
new file mode 100644
index 00000000..505aa5b8
--- /dev/null
+++ b/benchmarks/Makefile
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 1994, 1995 Free Software Foundation
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2, or (at
+# your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+dir := benchmarks
+makemode := utility
+
+SRCS = forks.c
+OBJS = forks.o
+target = forks
+
+include ../Makeconf
+
diff --git a/benchmarks/forks.c b/benchmarks/forks.c
new file mode 100644
index 00000000..30f01f72
--- /dev/null
+++ b/benchmarks/forks.c
@@ -0,0 +1,63 @@
+/* From 4.4 BSD sys/tests/benchmarks/forks.c. */
+
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+#include <sys/wait.h>
+
+/*
+ * Benchmark program to calculate fork+wait
+ * overhead (approximately). Process
+ * forks and exits while parent waits.
+ * The time to run this program is used
+ * in calculating exec overhead.
+ */
+
+int
+main(argc, argv)
+ char *argv[];
+{
+ register int nforks, i;
+ char *cp;
+ int pid, child, status, brksize;
+ time_t starttime, endtime;
+
+ if (argc < 3) {
+ printf("usage: %s number-of-forks sbrk-size\n", argv[0]);
+ exit(1);
+ }
+ nforks = atoi(argv[1]);
+ if (nforks < 0) {
+ printf("%s: bad number of forks\n", argv[1]);
+ exit(2);
+ }
+ brksize = atoi(argv[2]);
+ if (brksize < 0) {
+ printf("%s: bad size to sbrk\n", argv[2]);
+ exit(3);
+ }
+
+ time (&starttime);
+ cp = (char *)sbrk(brksize);
+ if ((int)cp == -1) {
+ perror("sbrk");
+ exit(4);
+ }
+ for (i = 0; i < brksize; i += 1024)
+ cp[i] = i;
+ while (nforks-- > 0) {
+ child = fork();
+ if (child == -1) {
+ perror("fork");
+ exit(-1);
+ }
+ if (child == 0)
+ _exit(-1);
+ while ((pid = wait(&status)) != -1 && pid != child)
+ ;
+ }
+ time (&endtime);
+ printf ("Time: %d seconds.\n", (int) (endtime - starttime));
+ exit(0);
+}