IODA Bundle
TestSetvbuffer.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2012 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 /// \file TestSetvbuffer.h
12 ///
13 /// @author Piotr Kuchta, ECMWF, Feb 2009
14 
15 #include <sys/wait.h>
16 
17 #include "eckit/log/Timer.h"
18 #include "odc/ODBAPISettings.h"
19 
20 #include "odc/Writer.h"
21 #include "TestCase.h"
22 
23 using namespace std;
24 using namespace eckit;
25 using namespace odc;
26 
27 
28 
29 static void setUp() { }
30 
31 
32 static void createFile(size_t numberOfColumns, long long numberOfRows, size_t setvbufferSize)
33 {
34 
35  ODBAPISettings::instance().setvbufferSize(setvbufferSize);
36 
37  odc::Writer<> oda("TestSetvbuffer.odb");
38  odc::Writer<>::iterator row = oda.begin();
39 
40  row->setNumberOfColumns(numberOfColumns);
41 
42  for (size_t i = 0; i < numberOfColumns; ++i)
43  {
44  stringstream name;
45  name << "Column" << i;
46  row->setColumn(i, name.str().c_str(), odc::api::REAL);
47  }
48  row->writeHeader();
49 
50  for (long long i = 1; i <= numberOfRows; ++i, ++row)
51  for (size_t c = 0; c < numberOfColumns; ++c)
52  (*row)[c] = c;
53 }
54 
55 static void tearDown()
56 {
57  int catStatus = system("ls -l TestSetvbuffer.odb");
58  ASSERT(WEXITSTATUS(catStatus) == 0);
59 }
60 
61 
62 static void test()
63 {
64  size_t cols = 400;
65  long long rows = 1000;
66  size_t buffSize = 8 * 1024 * 1024;
67 
68  for (size_t i = 0; i < 10; ++i)
69  {
70  stringstream s;
71  s << "setUp(): createFile(" << cols << ", " << rows << ", " << buffSize << ")" << std::endl;
72  Timer t(s.str());
73  createFile(cols, rows, buffSize);
74  }
75 }
76 
77 
78 
79 SIMPLE_TEST(Setvbuffer)
void oda
#define SIMPLE_TEST(name)
Definition: TestCase.h:66
static void tearDown()
static void createFile(size_t numberOfColumns, long long numberOfRows, size_t setvbufferSize)
static void test()
static void setUp()
void writeHeader()
void setNumberOfColumns(size_t n)
Definition: IteratorProxy.h:95
int setColumn(size_t index, const std::string &name, api::ColumnType type)
Definition: ColumnInfo.h:23
Definition: encode.cc:30