This forum has been archived. Please start a new discussion on GitHub.

performance difference


i'm playing with ICE today. everything is ok untill i do some performace benchmark. you can reproduce this as following:

1. modify demo Hello:Client.cpp:72, i want to run "twoWay->sayHello" for 1000 times for benchmark. add some timer functions before and after this.
2. modify demo Hello:HelloI.cpp:18, comment out "cout << "Hello World!" << endl".
3. run client.exe, which will print the time 1 for sayHello.
4. modify demo Hello:HelloI.cpp:18, add "::Sleep(1);".
5. run client.exe, which will print the time 2 for sayHello.

here is the result on my box:
time 1: 584msec (about 0.5msec for one call)
time 2: 15656msec (about 15msec for one call)

as i thought, time 2 should be about 1500msec, but the result is about 15000msec.

i modified ::Sleep(1) to Sleep(2), Sleep(4), Sleep(8), the value were about 15000msec (it's strange, isn't it?)

even, i modify the to use "ami", and set threadpool to 10 (client and server) is not help (as i thought, "AMI" should work under this condition).

i thought it's a bug, if you have any good reason, please move to related thread.

my test environment:
NET: localhost (client and server is in same machine)
VER: ICE-2.1.1 precompiled

modified client.cpp
for(int i = 0; i < 1000; ++i) {
cout << "\n" << beg.wHour << ":" << beg.wMinute << ":" << beg.wSecond << "." << beg.wMilliseconds
<< "\n" << end.wHour << ":" << end.wMinute << ":" << end.wSecond << "." << end.wMilliseconds
<< endl;

modified helloI.cpp
// cout << "Hello World!" << endl;


  • benoit
    benoit Rennes, France
    The resolution for the Win32 time methods is limited to something around 10ms -- so sleeping for a value inferior to 10ms won't give you the expected result. Your code work just fine on another OS with higher timer resolution (I tried on Mac OS X). See this MSDN article for some information on time resolution on Windows.

  • marc
    marc Florida
    I believe the average sleep time of a ::Sleep(1) is much higher than one millisecond. Run a test program to find out how long ::Sleep(1) really sleeps. You can also do a Google search on this topic. I just found this page:
  • i'll try this at home

    thanks for your reply. i'll try this at home...:)