diff options
author | David Robillard <d@drobilla.net> | 2011-04-28 18:19:28 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2011-04-28 18:19:28 +0000 |
commit | 0d229deb0d6059e997d69207e152343ef811da80 (patch) | |
tree | 54c2163fa1eb0f848204e7e9841a58b934dad5ef /test/midi_ringbuffer_test.cpp | |
parent | 4378875d3c74b4fa501e92d6e11837c7fe67c525 (diff) | |
download | raul-0d229deb0d6059e997d69207e152343ef811da80.tar.gz raul-0d229deb0d6059e997d69207e152343ef811da80.tar.bz2 raul-0d229deb0d6059e997d69207e152343ef811da80.zip |
Improve RingBuffer implementation.
Previous implementation was broken when written to full capacity, and
this version is significantly faster as well.
git-svn-id: http://svn.drobilla.net/lad/trunk/raul@3213 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'test/midi_ringbuffer_test.cpp')
-rw-r--r-- | test/midi_ringbuffer_test.cpp | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/test/midi_ringbuffer_test.cpp b/test/midi_ringbuffer_test.cpp deleted file mode 100644 index fed3ca0..0000000 --- a/test/midi_ringbuffer_test.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include <iostream> -#include <cstring> -#include <cstdio> -#include <stdio.h> -#include "raul/TimeStamp.hpp" -#include "raul/EventRingBuffer.hpp" -#include "raul/midi_names.h" - -using namespace std; -using namespace Raul; - -int -read_write_test(EventRingBuffer& rb, unsigned offset) -{ - TimeStamp t(TimeUnit(TimeUnit::FRAMES, 48000), 0, 0); - size_t size; - unsigned char write_buf[5]; - unsigned char read_buf[5]; - - snprintf(reinterpret_cast<char*>(write_buf), 5, "%d", offset); - size = strlen(reinterpret_cast<const char*>(write_buf)); - -#ifndef NDEBUG - const size_t written = rb.write(t, size, write_buf); - assert(written == size); -#endif - - rb.read(&t, &size, read_buf); - - return strncmp( - reinterpret_cast<const char*>(write_buf), - reinterpret_cast<const char*>(read_buf), - size); -} - - -int -main() -{ - EventRingBuffer rb(32); - - for (size_t i = 0; i < 100000; ++i) - if (read_write_test(rb, i)) - return 1; - - return 0; -} - |