mirror of
https://github.com/boostorg/iostreams.git
synced 2026-02-26 16:52:24 +00:00
removed incomplete performance tests
[SVN r27133]
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
// (C) Copyright Jonathan Turkanis 2004
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
||||
|
||||
// See http://www.boost.org/libs/iostreams for documentation.
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "./file_stream_test.hpp"
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite(int, char* [])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("file stream test");
|
||||
test->add(BOOST_TEST_CASE(&file_stream_test));
|
||||
return test;
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
// (C) Copyright Jonathan Turkanis 2004
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
||||
|
||||
// See http://www.boost.org/libs/iostreams for documentation.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_PERF_FILE_STREAM_TEST_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_PERF_FILE_STREAM_TEST_HPP_INCLUDED
|
||||
|
||||
#define USE_BLOCK_STREAMBUF
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <boost/iostreams/file.hpp>
|
||||
#include <boost/iostreams/file_descriptor.hpp>
|
||||
#include <boost/iostreams/stream_facade.hpp>
|
||||
#include <boost/progress.hpp>
|
||||
#include "../test/detail/verification.hpp"
|
||||
|
||||
void remove_all(int trials)
|
||||
{
|
||||
char temp_name[30];
|
||||
for (int z = 0; z < trials; ++z) {
|
||||
sprintf(temp_name, "C:/temp/tmp%d", z);
|
||||
remove(temp_name);
|
||||
}
|
||||
}
|
||||
|
||||
void file_stream_test()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
using namespace boost::iostreams;
|
||||
using namespace boost::iostreams::test;
|
||||
|
||||
int trials_per_run = 100;
|
||||
int runs = 400;
|
||||
double elapsed1 = 0, elapsed2 = 0;
|
||||
char temp_name[30];
|
||||
|
||||
remove_all(trials_per_run);
|
||||
|
||||
for (int w = 0; w < runs; ++w) {
|
||||
|
||||
{
|
||||
timer t;
|
||||
stream_facade<file_descriptor_sink> out;
|
||||
ios_base::openmode mode =
|
||||
ios_base::out | ios_base::trunc;
|
||||
for (int z = 0; z < trials_per_run; ++z) {
|
||||
sprintf(temp_name, "C:/temp/tmp%d", z);
|
||||
out.open(file_descriptor_sink(temp_name, mode));
|
||||
write_data_in_chunks(out);
|
||||
out.close();
|
||||
}
|
||||
elapsed1 += t.elapsed();
|
||||
}
|
||||
|
||||
remove_all(trials_per_run);
|
||||
|
||||
{
|
||||
timer t;
|
||||
std::ofstream out;
|
||||
std::ios_base::openmode mode =
|
||||
std::ios_base::out | std::ios_base::trunc;
|
||||
for (int z = 0; z < trials_per_run; ++z) {
|
||||
sprintf(temp_name, "C:/temp/tmp%d", z);
|
||||
out.open(temp_name, mode);
|
||||
test::write_data_in_chunks(out);
|
||||
out.close();
|
||||
}
|
||||
elapsed2 += t.elapsed();
|
||||
}
|
||||
|
||||
remove_all(trials_per_run);
|
||||
}
|
||||
|
||||
cout << "total time stream_facade<file_descriptor_sink>: " << elapsed1 << "s\n";
|
||||
cout << "total time std::ofstream: " << elapsed2 << "s\n";
|
||||
|
||||
}
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_PERF_FILE_STREAM_TEST_HPP_INCLUDED
|
||||
@@ -1,17 +0,0 @@
|
||||
// (C) Copyright Jonathan Turkanis 2004
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
||||
|
||||
// See http://www.boost.org/libs/iostreams for documentation.
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include "./string_stream_test.hpp"
|
||||
|
||||
using boost::unit_test_framework::test_suite;
|
||||
|
||||
test_suite* init_unit_test_suite(int, char* [])
|
||||
{
|
||||
test_suite* test = BOOST_TEST_SUITE("string stream test");
|
||||
test->add(BOOST_TEST_CASE(&string_stream_test));
|
||||
return test;
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
// (C) Copyright Jonathan Turkanis 2004
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
|
||||
|
||||
// See http://www.boost.org/libs/iostreams for documentation.
|
||||
|
||||
#ifndef BOOST_IOSTREAMS_PERF_STRING_STREAM_TEST_HPP_INCLUDED
|
||||
#define BOOST_IOSTREAMS_PERF_STRING_STREAM_TEST_HPP_INCLUDED
|
||||
|
||||
#define USE_BLOCK_STREAMBUF
|
||||
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <boost/iostreams/container_device.hpp>
|
||||
#include <boost/iostreams/stream_facade.hpp>
|
||||
#include <boost/progress.hpp>
|
||||
#include "../test/detail/verification.hpp"
|
||||
|
||||
struct string_sink {
|
||||
typedef char char_type;
|
||||
typedef boost::iostreams::sink_tag io_category;
|
||||
typedef boost::iostreams::detail::buffer<char> buffer_type;
|
||||
string_sink() : buf_(new buffer_type(0)) { }
|
||||
void write(const char* s, std::streamsize n)
|
||||
{
|
||||
int size = (int) (buf().ptr() - buf().begin());
|
||||
if (buf().ptr() - buf().begin() + n > buf().size())
|
||||
grow(n);
|
||||
size = (int) (buf().ptr() - buf().begin());
|
||||
memcpy(buf().ptr(), s, n);
|
||||
buf().ptr() += n;
|
||||
}
|
||||
void grow(std::streamsize length)
|
||||
{
|
||||
length += buf().size();
|
||||
length *= 1.5;
|
||||
boost::iostreams::detail::buffer<char> tmp(length);
|
||||
std::streamsize valid =
|
||||
static_cast<std::streamsize>(buf().ptr() - buf().data());
|
||||
tmp.ptr() += valid;
|
||||
memcpy(tmp.data(), buf().data(), valid);
|
||||
buf().swap(tmp);
|
||||
}
|
||||
std::string str() const
|
||||
{
|
||||
return std::string(buf().data(), buf().ptr());
|
||||
}
|
||||
buffer_type& buf() const { return *buf_; }
|
||||
boost::shared_ptr<buffer_type> buf_;
|
||||
};
|
||||
|
||||
void string_stream_test()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace boost;
|
||||
using namespace boost::iostreams;
|
||||
using namespace boost::iostreams::test;
|
||||
typedef container_device<string, seekable> seekable_string;
|
||||
typedef container_device<vector<char>, seekable> seekable_vector;
|
||||
|
||||
int trials_per_run = 100;
|
||||
int runs = 400;
|
||||
double elapsed1 = 0, elapsed2 = 0;
|
||||
|
||||
for (int w = 0; w < runs; ++w) {
|
||||
|
||||
{
|
||||
timer t;
|
||||
stream_facade<string_sink> out;
|
||||
for (int z = 0; z < trials_per_run; ++z) {
|
||||
out.open(string_sink(), 0, 0);
|
||||
write_data_in_chunks(out);
|
||||
out.close();
|
||||
}
|
||||
elapsed1 += t.elapsed();
|
||||
}
|
||||
|
||||
{
|
||||
timer t;
|
||||
std::stringstream out;
|
||||
for (int z = 0; z < trials_per_run; ++z) {
|
||||
out.str("");
|
||||
write_data_in_chunks(out);
|
||||
}
|
||||
elapsed2 += t.elapsed();
|
||||
}
|
||||
}
|
||||
|
||||
cout << "total time stream_facade<seekable_string>: " << elapsed1 << "s\n";
|
||||
cout << "total time std::stringstream: " << elapsed2 << "s\n";
|
||||
}
|
||||
|
||||
#endif // #ifndef BOOST_IOSTREAMS_PERF_STRING_STREAM_TEST_HPP_INCLUDED
|
||||
Reference in New Issue
Block a user