Skip to content

Queue testing

jcfreeman2 edited this page Jul 1, 2020 · 6 revisions

In the appfwk package, an executable for queue testing called queue_IO_check exists which writes and reads integers to instances of classes which implement the appfwk's Queue interface class. It has several adjustable parameters, including the number of threads doing the writing, the number of threads doing the reading, the number of integers you want to write/read, and the type of queue you want to test.

To use it, you'll want to set up the appfwk environment as described here. queue_IO_check has several adjustable parameters which take on defaults, but for starters you can run it without arguments. If you're in the base of your development area you can just do the following:

./build/appfwk/test/queue_IO_check 

What this will do is take an empty instance of the StdDeQueue class, and have one thread writing (pushing) one million integers onto the queue with another thread reading (popping) them. When you're done, you'll see something like the following:

06-30 15:47:12.344986   TRACE nfo 1 thread(s) pushing 1000000 elements between them, each thread has an average time of 0 milliseconds between pushes
06-30 15:47:12.345063   TRACE nfo 1 thread(s) popping 1000000 elements between them, each thread has an average time of 0 milliseconds between pops
06-30 15:47:16.248345   TRACE nfo Max queue size during running was 106273
06-30 15:47:16.248367   TRACE nfo Final queue size at the end of running is 0
06-30 15:47:16.248373   TRACE nfo 1000000 push attempts made: 1000000 successful, 0 timeouts, 0 exception throws
06-30 15:47:16.248378   TRACE nfo 1000000 pop attempts made: 1000000 successful, 0 timeouts, 0 exception throws

In this particular instance, we see that the pushing/popping took just under four seconds, and that none of the push or pop calls timed out. Note that while the timeout is hardwired to 100 ms, this can be made an adjustable parameter in the future.

Optional arguments you'll find useful are the following:

--queue_type <type>

...where <type> can be FollySPSCQueue, FollyMPMCQueue, and StdDeQueue. These options will increase as new implementations of Queue become available.

--push_threads <# of threads>

...which is the number of threads pushing. Currently this must be >=1 (*), though in the case of FollySPSCQueue it can only be one.

--pop_threads <# of threads>

...which is the number of threads popping. This must be >=0; setting this to 0 means simply that you just want to see how long it takes to push the elements onto the queue without additional threads removing the elements. In the case of FollySPSCQueue it can only be 0 or 1.

--nelements <# of elements>

This will specify the number of elements which get pushed/popped onto/off of the queue. Must be >=1.

Note that when testing it can be convenient to use loops. E.g., you could do the following:

for queue in FollyMPMCQueue StdDeQueue ; do
  echo
  echo "Testing $queue:" 
  ./build/appfwk/test/queue_IO_check --push_threads 4 --pop_threads 1 --queue $queue 

done

if you wanted to see how the queues behaved with four threads trying to write data to them at once while just one thread read from them. You could also put such code in a bash script, to run it later.

(*) Although functionality will soon be added in which users can both specify that they want the queue to start off nonempty and that they want 0 pushing threads, in which case the program becomes a test solely of the popping functionality of the queue.

Clone this wiki locally