Don't call Random.uniform() unnecessarily
authorAli Saidi <saidi@eecs.umich.edu>
Wed, 2 Nov 2005 20:29:08 +0000 (15:29 -0500)
committerAli Saidi <saidi@eecs.umich.edu>
Wed, 2 Nov 2005 20:29:08 +0000 (15:29 -0500)
--HG--
extra : convert_revision : 82b092391f7c866f33ddb028070181038bdce0f8

dev/etherlink.cc

index f5c47bd229ce3dcc2797a546808c5cfdc6b4d8de..e0f45c3bfccbfacfb0d7f589350adc07b82b8bb9 100644 (file)
@@ -159,9 +159,11 @@ EtherLink::Link::transmit(PacketPtr pkt)
     DDUMP(EthernetData, pkt->data, pkt->length);
 
     packet = pkt;
-    Random<Tick> var;
-    Tick delay = (Tick)ceil(((double)pkt->length * ticksPerByte) + 1.0 +
-                            var.uniform(delayVar));
+    Tick delay = (Tick)ceil(((double)pkt->length * ticksPerByte) + 1.0);
+    if (delayVar != 0) {
+        Random<Tick> var;
+        delay +=  var.uniform(delayVar);
+    }
     DPRINTF(Ethernet, "scheduling packet: delay=%d, (rate=%f)\n",
             delay, ticksPerByte);
     doneEvent.schedule(curTick + delay);