diff options
author | Bernard Normier <bernard@zeroc.com> | 2007-03-20 18:27:21 +0000 |
---|---|---|
committer | Bernard Normier <bernard@zeroc.com> | 2007-03-20 18:27:21 +0000 |
commit | aaa75d85cd5e17da09f38d81bc9d3ca0a2472eff (patch) | |
tree | f0984b3c4682abdabd00ee9fab9b5dd078b8ca6f /cpp | |
parent | - Remove bogus commented out code from LoggerI.java (diff) | |
download | ice-aaa75d85cd5e17da09f38d81bc9d3ca0a2472eff.tar.bz2 ice-aaa75d85cd5e17da09f38d81bc9d3ca0a2472eff.tar.xz ice-aaa75d85cd5e17da09f38d81bc9d3ca0a2472eff.zip |
customeEvictor
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Freeze/Makefile.mak | 1 | ||||
-rw-r--r-- | cpp/demo/Freeze/README | 5 | ||||
-rw-r--r-- | cpp/demo/Freeze/customEvictor/Client.cpp | 19 | ||||
-rw-r--r-- | cpp/demo/Freeze/customEvictor/Makefile | 6 | ||||
-rwxr-xr-x | cpp/demo/Freeze/customEvictor/Makefile.mak | 68 | ||||
-rw-r--r-- | cpp/demo/Freeze/customEvictor/Server.cpp | 2 | ||||
-rw-r--r-- | cpp/demo/Freeze/customEvictor/db/DB_CONFIG | 2 |
7 files changed, 89 insertions, 14 deletions
diff --git a/cpp/demo/Freeze/Makefile.mak b/cpp/demo/Freeze/Makefile.mak index 01e773ade86..77b65097367 100644 --- a/cpp/demo/Freeze/Makefile.mak +++ b/cpp/demo/Freeze/Makefile.mak @@ -12,6 +12,7 @@ top_srcdir = ..\.. !include $(top_srcdir)\config\Make.rules.mak SUBDIRS = bench \ + customEvictor \ library \ phonebook diff --git a/cpp/demo/Freeze/README b/cpp/demo/Freeze/README index 6cd6ea1b1a8..12c8c5fe65a 100644 --- a/cpp/demo/Freeze/README +++ b/cpp/demo/Freeze/README @@ -9,6 +9,11 @@ Demos in this directory: A simple benchmark to measure the performance of Freeze for various data types. +- customEvictor + + Illustrates how to write your own evictor, using either IceUtil::Cache + or EvictorBase. + - library A simple application that allows you to borrow books from a library. diff --git a/cpp/demo/Freeze/customEvictor/Client.cpp b/cpp/demo/Freeze/customEvictor/Client.cpp index ff795c08d54..37fe8a6a01e 100644 --- a/cpp/demo/Freeze/customEvictor/Client.cpp +++ b/cpp/demo/Freeze/customEvictor/Client.cpp @@ -14,6 +14,9 @@ using namespace std; using namespace Warehouse; +const int readCount = 15000; +const int writeCount = 1500; + const int objectCount = 10000; class WarehouseClient : public Ice::Application @@ -73,16 +76,14 @@ public: virtual void run() { // - // Measures how long it takes to read 'count' items at random + // Measures how long it takes to read 'readCount' items at random // - const int count = 50000; - StopWatch stopWatch; stopWatch.start(); try { - for(int i = 0; i < count; ++i) + for(int i = 0; i < readCount; ++i) { int id = IceUtil::random(objectCount); ostringstream os; @@ -93,7 +94,7 @@ public: ItemPrx item = ItemPrx::uncheckedCast(_anItem->ice_identity(identity)); item->getDescription(); } - _requestsPerSecond = static_cast<int>(count / stopWatch.stop().toSecondsDouble()); + _requestsPerSecond = static_cast<int>(readCount / stopWatch.stop().toSecondsDouble()); } catch(const IceUtil::Exception& e) { @@ -128,16 +129,14 @@ public: virtual void run() { // - // Measure how long it takes to write 'count' items at random + // Measure how long it takes to write 'writeCount' items at random // - const int count = 5000; - StopWatch stopWatch; stopWatch.start(); try { - for(int i = 0; i < count; ++i) + for(int i = 0; i < writeCount; ++i) { int id = IceUtil::random(objectCount); @@ -150,7 +149,7 @@ public: item->adjustStock(1); } - _requestsPerSecond = static_cast<int>(count / stopWatch.stop().toSecondsDouble()); + _requestsPerSecond = static_cast<int>(writeCount / stopWatch.stop().toSecondsDouble()); } catch(const IceUtil::Exception& e) { diff --git a/cpp/demo/Freeze/customEvictor/Makefile b/cpp/demo/Freeze/customEvictor/Makefile index a10dda80048..1225a054f58 100644 --- a/cpp/demo/Freeze/customEvictor/Makefile +++ b/cpp/demo/Freeze/customEvictor/Makefile @@ -27,7 +27,9 @@ SOBJS = ItemInfo.o \ SimpleEvictor.o \ Server.o -SRCS = $(OBJS:.o=.cpp) +SRCS = $(OBJS:.o=.cpp) \ + $(COBJS:.o=.cpp) \ + $(SOBJS:.o=.cpp) SLICE_SRCS = Item.ice ItemInfo.ice @@ -44,7 +46,7 @@ $(SERVER): $(OBJS) $(SOBJS) $(CXX) $(LDFLAGS) -o $@ $(OBJS) $(SOBJS) $(DB_RPATH_LINK) -lFreeze $(LIBS) -Database.h Database.cpp: $(SLICE2FREEZE) +Database.h Database.cpp: ItemInfo,ice $(SLICE2FREEZE) rm -f Database.h Database.cpp $(SLICE2FREEZE) -I$(slicedir) --dict Database,string,Warehouse::ItemInfo Database ItemInfo.ice diff --git a/cpp/demo/Freeze/customEvictor/Makefile.mak b/cpp/demo/Freeze/customEvictor/Makefile.mak new file mode 100755 index 00000000000..6e6b6f7751f --- /dev/null +++ b/cpp/demo/Freeze/customEvictor/Makefile.mak @@ -0,0 +1,68 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ..\..\.. + +CLIENT = client.exe +SERVER = server.exe + +TARGETS = $(CLIENT) $(SERVER) + +OBJS = Item.obj + +COBJS = Client.obj + +SOBJS = ItemInfo.obj \ + Database.obj \ + CurrentDatabase.obj \ + ItemI.obj \ + Evictor.obj \ + EvictorBase.obj \ + SimpleEvictor.obj \ + Server.obj + +SRCS = $(OBJS:.obj=.cpp) \ + $(COBJS:.obj=.cpp) \ + $(SOBJS:.obj=.cpp) + +SLICE_SRCS = Item.ice ItemInfo.ice + +!include $(top_srcdir)/config/Make.rules.mak + +CPPFLAGS = -I. $(CPPFLAGS) -DWIN32_LEAN_AND_MEAN + +!if "$(CPP_COMPILER)" != "BCC2006" & "$(OPTIMIZE)" != "yes" +CPDBFLAGS = /pdb:$(CLIENT:.exe=.pdb) +SPDBFLAGS = /pdb:$(SERVER:.exe=.pdb) +COPDBFLAGS = /pdb:$(COLLOCATED:.exe=.pdb) +!endif + + +$(CLIENT): $(OBJS) $(COBJS) + $(LINK) $(LD_EXEFLAGS) $(CPDBFLAGS) $(SETARGV) $(OBJS) $(COBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + +$(SERVER): $(OBJS) $(SOBJS) + $(LINK) $(LD_EXEFLAGS) $(SPDBFLAGS) $(SETARGV) $(OBJS) $(SOBJS) $(PREOUT)$@ $(PRELIBS)$(LIBS) freeze$(LIBSUFFIX).lib + @if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \ + $(MT) -nologo -manifest $@.manifest -outputresource:$@;#1 && del /q $@.manifest + + +Database.h Database.cpp: ItemInfo.ice $(SLICE2FREEZE) + del /q Database.h Database.cpp + $(SLICE2FREEZE) -I$(slicedir) --dict Database,string,Warehouse::ItemInfo Database ItemInfo.ice + +cleandb: + del /q db\log.* db\__catalog db\items + +clean:: cleandb + del /q Database.h Database.cpp + +include .depend diff --git a/cpp/demo/Freeze/customEvictor/Server.cpp b/cpp/demo/Freeze/customEvictor/Server.cpp index aa6aabd1fc6..e794ab48fe3 100644 --- a/cpp/demo/Freeze/customEvictor/Server.cpp +++ b/cpp/demo/Freeze/customEvictor/Server.cpp @@ -77,7 +77,7 @@ WarehouseServer::run(int argc, char* argv[]) os << "P/N " << i; string name = os.str(); info.description = "The description of " + name; - info.unitPrice = i + 0.95; + info.unitPrice = i + 0.95f; info.quantityInStock = i; info.filler = string(5000, 'x'); diff --git a/cpp/demo/Freeze/customEvictor/db/DB_CONFIG b/cpp/demo/Freeze/customEvictor/db/DB_CONFIG index 5a4fc6bf468..44cc87c95e6 100644 --- a/cpp/demo/Freeze/customEvictor/db/DB_CONFIG +++ b/cpp/demo/Freeze/customEvictor/db/DB_CONFIG @@ -2,7 +2,7 @@ #set_cachesize 0 20480 1 # about 128K -set_cachesize 0 128000 1 +#set_cachesize 0 128000 1 # about 100MB #set_cachesize 0 100000000 1 |