SPBench Benchmarks
==================

.. _benchmarks:

.. contents:: Table of Contents

Single source benchmarks
------------------------

These are the commom benchmarks. They read data from a single input and generate a single stream of input and output data. The source operator runs inside the stream region, as shown in the example below.

.. code-block:: C++

   int main (int argc, char* argv[]){

      /* Init of stream region */
      while(1){
         spb::Item item;
         if(!spb::Source::op(item)) break;
         spb::First::op(item);
         spb::Second::op(item);
         spb::Nth::op(item);
         spb::Sink::op(item);
      } // End of stream region

      return 0;
   }


Multiple source benchmarks
--------------------------

These are benchmarks that can read data from different inputs and generate multiple input/output streams. Here, the n source operators are run each by a exclusive thread outside the stream region. Each source has its own queue with items that can be accessed by a getItem() method inside the stream region, as shown in the example below.

.. code-block:: C++

   int main (int argc, char* argv[]){

      spb::Source source1;
      spb::Source source2;

      source1.init();
      source2.init();

      /* Stream region */
      while(!(source1.depleted() && source2.depleted())){

         spb::Item item1 = source1.getItem();
         spb::Item item2 = source2.getItem();

         spb::First::op(item1);
         spb::First::op(item2);

         spb::Nth::op(item1);
         spb::Nth::op(item2); 
         
         spb::Sink::op(item1);
         spb::Sink::op(item2);
      }
      return 0;
   }
   
	
