官术网_书友最值得收藏!

Comparing the two solutions

Now it's time to test the serial and concurrent servers and see which has a better performance. We have automatized the tests implementing four classes that make queries to the servers. These classes are:

  • SerialClient: This implements a possible client of the serial server. It makes nine requests using the query message and a query using the report message. It repeats the process 10 times, so it request 90 queries and 10 reports.
  • MultipleSerialClients: This class simulates the existence of several clients at the same time. For this, we create a thread per SerialClient and execute them at the same time to see the performance of the server. We have tested from one to five concurrent clients.
  • ConcurrentClient: It is analogue to the SerialClient class, but it calls the concurrent server instead of the serial one.
  • MultipleConcurrentClients: It is analogue to the MultipleSerialClients class, but it calls the concurrent server instead of the serial one.

To test the serial server, you can follow these steps:

  1. Launch the serial server and wait for its initialization.
  2. Launch the MultipleSerialClients class, which launches one, then two, three, four, and finally, five SerialClient classes.

You can follow a similar process with the concurrent server:

  1. Launch the concurrent server and wait for its initialization.
  2. Launch the MultipleConcurrentClients class, which launches one, two, three, four, and finally, five ConcurrentClient classes.

To compare the execution times of both versions, we have implemented a microbenchmark using the JMH framework (http://openjdk.java.net/projects/code-tools/jmh/). We have implemented two executions based in the SerialClient and ConcurrentClient tasks. We have repeated this process 10 times calculating the mean time per number of concurrent clients. We launched the tests in a computer with a processor with four cores, so it can execute four parallel tasks at the same time.

These are the results of all these executions:

The contents of the cells are the mean time of each client in seconds. We can draw the following conclusions:

  • The performance of both kinds of servers is affected by the number of concurrent clients that send requests to our server
  • In all cases, the execution times of the concurrent version are much lower than the execution times of the serial one
主站蜘蛛池模板: 兴安盟| 视频| 河北区| 汉阴县| 巧家县| 姚安县| 应城市| 荣成市| 济源市| 安达市| 观塘区| 白河县| 诸暨市| 九龙城区| 昌乐县| 乌恰县| 江西省| 乌恰县| 长丰县| 民权县| 渭源县| 贵州省| 千阳县| 体育| 乌恰县| 昌黎县| 永宁县| 兴国县| 尤溪县| 资中县| 察哈| 准格尔旗| 玛纳斯县| 肃北| 闵行区| 奉节县| 永城市| 太白县| 邯郸县| 怀仁县| 吉隆县|