2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $XConsortium: pool.cc /main/3 1996/06/11 17:34:18 cde-hal $
26 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
27 * All rights reserved. Unpublished -- rights reserved under
28 * the Copyright Laws of the United States. USE OF A COPYRIGHT
29 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
32 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
33 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
34 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
35 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
38 * RESTRICTED RIGHTS LEGEND
39 * Use, duplication, or disclosure by the Government is subject
40 * to the restrictions as set forth in subparagraph (c)(l)(ii)
41 * of the Rights in Technical Data and Computer Software clause
42 * at DFARS 252.227-7013.
44 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
51 #include "storage/memory_pool.h"
52 #include "utility/xtime.h"
59 MESSAGE(cerr, "pool alloc/free test1");
64 for ( int i=0; i<NUMS; i++ ) {
65 ptrs[i] = x.alloc(SIZE);
68 MESSAGE(cerr, "alloc done!");
70 for ( i=0; i<NUMS; i++ ) {
73 MESSAGE(cerr, "free done!");
78 MESSAGE(cerr, "pool alloc/free test2");
83 for ( int i=0; i<NUMS/100; i++ ) {
85 for ( int j=0; j<100; j++ ) {
86 ptrs[j] = x.alloc(SIZE);
90 for ( j=0; j<100; j++ ) {
100 MESSAGE(cerr, "new/delete test1");
103 for ( int i=0; i<NUMS; i++ ) {
104 ptrs[i] = new char[SIZE];
107 MESSAGE(cerr, "alloc done!");
109 for ( i=NUMS-1; i>=0; i-- ) {
112 MESSAGE(cerr, "free done!");
117 MESSAGE(cerr, "new/delete test2");
120 for ( int i=0; i<NUMS/100; i++ ) {
122 for ( int j=0; j<100; j++ ) {
123 ptrs[j] = new char[SIZE];
127 for ( j=0; j<100; j++ ) {
134 main( int argc, char** argv )
136 assert ( argc == 2 );
145 if ( strcmp(argv[1], "-pool1") == 0 ) {
149 if ( strcmp(argv[1], "-pool2") == 0 ) {
153 if ( strcmp(argv[1], "-new1") == 0 ) {
157 if ( strcmp(argv[1], "-new2") == 0 ) {
162 MESSAGE(cerr, "apply a param: -pool[1|2] or -new[1|2]");
166 tm.duration(cpu, elap);