Commit 1c1b11a6 authored by neverlord's avatar neverlord

benchmarking stuff

parent ca075dbb
......@@ -5,3 +5,5 @@ test
*.png
*.dat
queue_test
8threads
4threads
......@@ -60,14 +60,14 @@
<valuemap type="QVariantMap">
<value key="ProjectExplorer.BuildConfiguration.DisplayName" type="QString">all</value>
<valuelist key="abstractProcess.Environment" type="QVariantList">
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-acy9jv/Render</value>
<value type="QString">Apple_PubSub_Socket_Render=/tmp/launch-tO8Wwx/Render</value>
<value type="QString">COMMAND_MODE=unix2003</value>
<value type="QString">DISPLAY=/tmp/launch-Dz1e1O/org.x:0</value>
<value type="QString">DISPLAY=/tmp/launch-w1qNYf/org.x:0</value>
<value type="QString">HOME=/Users/neverlord</value>
<value type="QString">LOGNAME=neverlord</value>
<value type="QString">PATH=/usr/bin:/bin:/usr/sbin:/sbin</value>
<value type="QString">SHELL=/bin/bash</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-AouAZz/Listeners</value>
<value type="QString">SSH_AUTH_SOCK=/tmp/launch-dnUZas/Listeners</value>
<value type="QString">TMPDIR=/var/folders/SE/SEReyCW0H-yDPCnNCe8mN++++TI/-Tmp-/</value>
<value type="QString">USER=neverlord</value>
<value type="QString">__CF_USER_TEXT_ENCODING=0x1F5:0:3</value>
......
......@@ -105,3 +105,5 @@ queue_performances/cached_stack.hpp
queue_performances/blocking_cached_stack.hpp
queue_performances/blocking_cached_stack2.hpp
queue_performances/blocking_sutter_list.hpp
queue_performances/lockfree_list.hpp
queue_performances/intrusive_sutter_list.hpp
set terminal png
set output "graph.png"
# Undefined variables: TITLE, FILE
#
# example:
# gnuplot -e "FILE='graph.png';TITLE='foobaz'" gnuplot_file
#set font "Arial"
#set terminal png
set terminal png font "Andale Mono"
#set output "graph.png"
set output FILE
unset log
unset label
set xtic auto
#set xtic auto
set xtic 10
set ytic auto
set xlabel "# messages (in 1,000,000)"
set ylabel "time (s)"
set ylabel "time (in seconds)"
set format y "%8.2f"
set xrange [1:110]
set yrange [0:120]
set grid
#set title "2.66 GHz i7 (dual core) with 8 producer threads"
set title TITLE
# "blocking_sutter_list.dat" using 1:2:3 title 'blocking sutter_list' lt 5 with errorbars, \
# "blocking_sutter_list.dat" notitle lt 5 with lines, \
# "blocking_cached_stack.dat" using 1:2:3 title 'blocking cached_stack' lt 4 with errorbars, \
# "blocking_cached_stack.dat" notitle lt 4 with lines, \
# "sutter_list.dat" using 1:2:3 title 'sutter_list' lt 3 with errorbars, \
# "sutter_list.dat" notitle lt 3 with lines, \
plot \
"blocking_sutter_list.dat" using 1:2:3 title 'blocking sutter_list' lt 5 with errorbars, \
"blocking_sutter_list.dat" notitle lt 5 with lines, \
"sutter_list.dat" using 1:2:3 title 'polling sutter_list' lt 3 with errorbars, \
"sutter_list.dat" notitle lt 3 with lines, \
"blocking_cached_stack.dat" using 1:2:3 title 'blocking cached_stack' lt 4 with errorbars, \
"blocking_cached_stack.dat" notitle lt 4 with lines, \
"cached_stack.dat" using 1:2:3 title 'polling cached_stack' lt 2 with errorbars, \
"intrusive_sutter_list.dat" using 1:2:3 title 'spinlock list' lt 4 with errorbars, \
"intrusive_sutter_list.dat" notitle lt 4 with lines, \
"lockfree_list.dat" using 1:2:3 title 'lockfree list' lt 1 with errorbars, \
"lockfree_list.dat" notitle lt 1 with lines, \
"michael_scott_lockfree.dat" using 1:2:3 title 'michael & scott' lt 3 with errorbars, \
"michael_scott_lockfree.dat" notitle lt 3 with lines, \
"cached_stack.dat" using 1:2:3 title 'cached stack' lt 2 with errorbars, \
"cached_stack.dat" notitle lt 2 with lines
quit
#!/bin/bash
for list in cached_stack blocking_cached_stack sutter_list blocking_sutter_list ; do
echo "benchmarking $list..."
rm -f "$list.dat"
for i in 1000000 2000000 3000000 4000000 5000000 6000000 7000000 8000000 9000000 10000000 ; do
_1=$(./queue_test $i 4 $list "\$TIME")
_2=$(./queue_test $i 4 $list "\$TIME")
_3=$(./queue_test $i 4 $list "\$TIME")
_4=$(./queue_test $i 4 $list "\$TIME")
_5=$(./queue_test $i 4 $list "\$TIME")
MID=$(echo "scale=50;($_1+$_2+$_3+$_4+$_5)/5" | bc)
MAX=$(echo "define max (x, y) { if (x < y) return (y); return (x); }; max(max(max(max($_1,$_2),$_3),$_4),$_5)" | bc)
MIN=$(echo "define min (x, y) { if (x < y) return (x); return (y); }; min(min(min(min($_1,$_2),$_3),$_4),$_5)" | bc)
POS_ERR=$(echo "$MAX-$MID" | bc)
NEG_ERR=$(echo "$MID-$MIN" | bc)
echo $[$i/1000000] $MID $POS_ERR $NEG_ERR >> "$list.dat"
NUM_THREADS=8
XUNIT=1000000
# $1 = list name
# $2 = num messages
function exec_queue_test()
{
echo "./queue_test $2 $NUM_THREADS $1"
# run test five times
_1=$(./queue_test $2 $NUM_THREADS $1 "\$TIME")
_2=$(./queue_test $2 $NUM_THREADS $1 "\$TIME")
_3=$(./queue_test $2 $NUM_THREADS $1 "\$TIME")
_4=$(./queue_test $2 $NUM_THREADS $1 "\$TIME")
_5=$(./queue_test $2 $NUM_THREADS $1 "\$TIME")
# get average runtime
MID=$(echo "scale=50;($_1+$_2+$_3+$_4+$_5)/5" | bc)
# get max. runtime
MAX=$(echo "define max (x, y) { if (x < y) return (y); return (x); }; max(max(max(max($_1,$_2),$_3),$_4),$_5)" | bc)
# get min. runtime
MIN=$(echo "define min (x, y) { if (x < y) return (x); return (y); }; min(min(min(min($_1,$_2),$_3),$_4),$_5)" | bc)
# error
ERR=$(echo "scale=50; $MAX-$MIN" | bc)
# X value for gnuplot
XVAL=$(echo "scale=4; $2/$XUNIT" | bc)
# print result to file
echo "$XVAL $MID $ERR" >> "$1.dat"
}
# $1 = list name
# $2 = minimum num messages
# $3 = maximum num messages
# $4 = step
function test_run()
{
#rm -f "$list.dat"
i=$2
while test "$i" -le "$3" ; do
exec_queue_test $1 $i
XVAL=$(echo "scale=4; $i/$XUNIT" | bc)
i=$[$i+$4]
done
}
#for list in intrusive_sutter_list cached_stack lockfree_list ; do
for list in michael_scott_lockfree ; do
echo "benchmarking $list ..."
rm -f "$list.dat"
test_run $list 1000000 10000000 9000000
test_run $list 20000000 110000000 10000000
done
echo "done"
gnuplot gnuplot_file
gnuplot -e "FILE='i7_${NUM_THREADS}threads.png';TITLE='2.66 GHz i7 (dual core) with $NUM_THREADS producer threads'" gnuplot_file
......@@ -10,7 +10,9 @@
#include "sutter_list.hpp"
#include "cached_stack.hpp"
#include "lockfree_list.hpp"
#include "blocking_sutter_list.hpp"
#include "intrusive_sutter_list.hpp"
#include "blocking_cached_stack.hpp"
#include "blocking_cached_stack2.hpp"
......@@ -39,12 +41,13 @@ template<typename Queue, typename Processor>
void consumer(Queue& q, Processor& p, size_t num_messages)
{
// vector<bool> scales better (in memory) than bool[num_messages]
std::vector<bool> received(num_messages);
for (size_t i = 0; i < num_messages; ++i) received[i] = false;
// std::vector<bool> received(num_messages);
// for (size_t i = 0; i < num_messages; ++i) received[i] = false;
for (size_t i = 0; i < num_messages; ++i)
{
size_t value;
p(q.pop(), value);
/*
if (value >= num_messages)
{
throw std::runtime_error("value out of bounds");
......@@ -56,6 +59,7 @@ void consumer(Queue& q, Processor& p, size_t num_messages)
throw std::runtime_error(oss.str());
}
received[value] = true;
*/
}
// done
}
......@@ -64,14 +68,15 @@ void usage()
{
cout << "usage:" << endl
<< "queue_test [messages] [producer threads] "
<< "[list impl.] {format string}"
<< endl
"[list impl.] {format string}" << endl
<< " available implementations:" << endl
<< " - sutter_list" << endl
<< " - intrusive_sutter_list" << endl
<< " - blocking_sutter_list" << endl
<< " - cached_stack" << endl
<< " - blocking_cached_stack" << endl
<< " - blocking_cached_stack2" << endl
<< " - lockfree_list" << endl
<< endl
<< " possible format string variables: " << endl
<< " - $MESSAGES" << endl
......@@ -158,6 +163,35 @@ int main(int argc, char** argv)
}
);
}
else if (list_name == "intrusive_sutter_list")
{
typedef intrusive_sutter_list<size_t> isl;
elapsed_time = run_test<isl>(
num_messages,
num_producers,
[] (size_t value) -> isl::node* {
return new isl::node(value);
},
[] (const size_t& value, size_t& storage) {
storage = value;
}
);
}
else if (list_name == "lockfree_list")
{
typedef lockfree_list<size_t> isl;
elapsed_time = run_test<isl>(
num_messages,
num_producers,
[] (size_t value) -> isl::node* {
return new isl::node(value);
},
[] (const size_t& value, size_t& storage) {
storage = value;
}
);
}
else if (list_name == "blocking_sutter_list")
{
elapsed_time = run_test<blocking_sutter_list<size_t>>(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment