1 // 2003-07-04 Petur Runolfsson <peturr02@ru.is>
3 // Copyright (C) 2003 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 2, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING. If not, write to the Free
18 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 // As a special exception, you may use this file as part of a free software
22 // library without restriction. Specifically, if other files instantiate
23 // templates or use macros or inline functions from this file, or you compile
24 // this file and link it with other files to produce an executable, this
25 // file does not by itself cause the resulting executable to be covered by
26 // the GNU General Public License. This exception does not however
27 // invalidate any other reasons why the executable file might be covered by
28 // the GNU General Public License.
35 // Contributed as part of libstdc++/11378.
36 int main(int argc, char** argv)
42 cerr << "Usage: " << argv[0] << " type iters [chunksize]\n";
46 enum { type_stdio, type_iostream } type;
48 if (!strcmp(argv[1], "stdio"))
50 else if (!strcmp(argv[1], "iostream"))
54 cerr << "Type must be one of {stdio, iostream}\n";
58 int iters = atoi(argv[2]);
61 cerr << "Iters must be an positive integer\n";
67 chunksize = atoi(argv[3]);
71 cerr << "Chunksize must be an positive integer\n";
78 chunk = new char[chunksize];
79 memset(chunk, 'a', chunksize);
86 FILE* f = fopen("tmp", "w");
87 setvbuf(f, 0, _IONBF, 0);
91 for (int i = 0; i < iters; ++i)
92 fwrite_unlocked(chunk, 1, chunksize, f);
96 for (int i = 0; i < iters; ++i)
97 putc_unlocked('a', f);
109 f.open("tmp", ios_base::out);
113 for (int i = 0; i < iters; ++i)
114 f.sputn(chunk, chunksize);
118 for (int i = 0; i < iters; ++i)