Next: , Previous: , Up: Examples   [Contents][Index]

5.1 Latency

One of the most common network performance benchmarks is a ping-pong latency test. Not surprisingly, such a test is straightforward to implement in coNCePTuaL:

# A ping-pong latency test written in coNCePTuaL

Require language version "1.5".

# Parse the command line.
reps is "Number of repetitions of each message size" and comes from
 "--reps" or "-r" with default 1000.
maxbytes is "Maximum number of bytes to transmit" and comes from
 "--maxbytes" or "-m" with default 1M.

# Ensure the we have a peer with whom to communicate.
Assert that "the latency test requires at least two tasks" with

# Perform the benchmark.
For each msgsize in {0}, {1, 2, 4, ..., maxbytes} {
  for reps repetitions {
    task 0 resets its counters then
    task 0 sends a msgsize byte message to task 1 then
    task 1 sends a msgsize byte message to task 0 then
    task 0 logs the msgsize as "Bytes" and
                the median of elapsed_usecs/2 as "1/2 RTT (usecs)"
  } then
  task 0 computes aggregates

Note that the outer FOR loop specifies two <range>s (see Range expressions). This is because ‘{0, 1, 2, 4, ..., maxbytes}’ is not a geometric progression. Hence, that incorrect <range> is split into the singleton ‘{0}’ and the geometric progression ‘{1, 2, 4, ..., maxbytes}’.

Scott Pakin,