utils/bench-packets.cc
changeset 54 f860e6f94787
parent 53 ae406f4957d5
child 110 9ac6d63bfe33
--- a/utils/bench-packets.cc	Tue Sep 05 13:13:39 2006 +0200
+++ b/utils/bench-packets.cc	Tue Sep 05 13:18:11 2006 +0200
@@ -1,4 +1,4 @@
-/* -*-	Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
+/* -*-    Mode:C++; c-basic-offset:4; tab-width:4; indent-tabs-mode:f -*- */
 /*
  * Copyright (c) 2006 INRIA
  * All rights reserved.
@@ -30,106 +30,106 @@
 static void 
 benchPtrA (uint32_t n)
 {
-	ChunkConstantData data = ChunkConstantData (2000, 1);
-	ChunkUdp udp;
-	ChunkIpv4 ipv4;
+    ChunkConstantData data = ChunkConstantData (2000, 1);
+    ChunkUdp udp;
+    ChunkIpv4 ipv4;
 
-	for (uint32_t i = 0; i < n; i++) {
-		Packet p;
-		p.add (&data);
-		p.add (&udp);
-		p.add (&ipv4);
-		Packet o = p;
-		o.peek (&ipv4);
-		o.remove (&ipv4);
-		o.peek (&udp);
-		o.remove (&udp);
-		o.peek (&data);
-		o.remove (&data);
-	}
+    for (uint32_t i = 0; i < n; i++) {
+        Packet p;
+        p.add (&data);
+        p.add (&udp);
+        p.add (&ipv4);
+        Packet o = p;
+        o.peek (&ipv4);
+        o.remove (&ipv4);
+        o.peek (&udp);
+        o.remove (&udp);
+        o.peek (&data);
+        o.remove (&data);
+    }
 }
 
 static void 
 benchPtrB (uint32_t n)
 {
-	ChunkConstantData data = ChunkConstantData (2000, 1);
-	ChunkUdp udp;
-	ChunkIpv4 ipv4;
+    ChunkConstantData data = ChunkConstantData (2000, 1);
+    ChunkUdp udp;
+    ChunkIpv4 ipv4;
 
-	for (uint32_t i = 0; i < n; i++) {
-		Packet p;
-		p.add (&data);
-		p.add (&udp);
-		p.add (&ipv4);
-	}
+    for (uint32_t i = 0; i < n; i++) {
+        Packet p;
+        p.add (&data);
+        p.add (&udp);
+        p.add (&ipv4);
+    }
 }
 
 static void
 ptrC2 (Packet p)
 {
-	ChunkConstantData data = ChunkConstantData (2000, 1);
-	ChunkUdp udp;
+    ChunkConstantData data = ChunkConstantData (2000, 1);
+    ChunkUdp udp;
 
-	p.peek (&udp);
-	p.remove (&udp);
-	p.peek (&data);
-	p.remove (&data);
+    p.peek (&udp);
+    p.remove (&udp);
+    p.peek (&data);
+    p.remove (&data);
 }
 
 static void 
 ptrC1 (Packet p)
 {
-	ChunkIpv4 ipv4;
-	p.peek (&ipv4);
-	p.remove (&ipv4);
-	ptrC2 (p);
+    ChunkIpv4 ipv4;
+    p.peek (&ipv4);
+    p.remove (&ipv4);
+    ptrC2 (p);
 }
 
 static void
 benchPtrC (uint32_t n)
 {
-	ChunkConstantData data = ChunkConstantData (2000, 1);
-	ChunkUdp udp;
-	ChunkIpv4 ipv4;
+    ChunkConstantData data = ChunkConstantData (2000, 1);
+    ChunkUdp udp;
+    ChunkIpv4 ipv4;
 
-	for (uint32_t i = 0; i < n; i++) {
-		Packet p;
-		p.add (&data);
-		p.add (&udp);
-		p.add (&ipv4);
-		ptrC1 (p);
-	}
+    for (uint32_t i = 0; i < n; i++) {
+        Packet p;
+        p.add (&data);
+        p.add (&udp);
+        p.add (&ipv4);
+        ptrC1 (p);
+    }
 }
 
 
 static void
 runBench (void (*bench) (uint32_t), uint32_t n, char const *name)
 {
-	WallClockMs time;
-	time.start ();
-	(*bench) (n);
-	unsigned long long deltaMs = time.end ();
-	double ps = n;
-	ps *= 1000;
-	ps /= deltaMs;
-	std::cout << name<<"=" << ps << " packets/s" << std::endl;
+    WallClockMs time;
+    time.start ();
+    (*bench) (n);
+    unsigned long long deltaMs = time.end ();
+    double ps = n;
+    ps *= 1000;
+    ps /= deltaMs;
+    std::cout << name<<"=" << ps << " packets/s" << std::endl;
 }
 
 int main (int argc, char *argv[])
 {
-	uint32_t n = 0;
-	while (argc > 0) {
-		if (strncmp ("--n=", argv[0],strlen ("--n=")) == 0) {
-			char const *nAscii = argv[0] + strlen ("--n=");
-			n = atoi (nAscii);
-		}
-		argc--;
-		argv++;
-	}
+    uint32_t n = 0;
+    while (argc > 0) {
+        if (strncmp ("--n=", argv[0],strlen ("--n=")) == 0) {
+            char const *nAscii = argv[0] + strlen ("--n=");
+            n = atoi (nAscii);
+        }
+        argc--;
+        argv++;
+    }
 
-	runBench (&benchPtrA, n, "a");
-	runBench (&benchPtrB, n, "b");
-	runBench (&benchPtrC, n, "c");
+    runBench (&benchPtrA, n, "a");
+    runBench (&benchPtrB, n, "b");
+    runBench (&benchPtrC, n, "c");
 
-	return 0;
+    return 0;
 }