result = EnumSet.copyOf(base);
564 | result.addAll(Arrays.asList(items));
565 | return result;
566 | }
567 |
568 |
569 | }
570 |
--------------------------------------------------------------------------------
/src/main/java/com/mycompany/app/model/TaxRate.java:
--------------------------------------------------------------------------------
1 | package com.mycompany.app.model;
2 |
3 | public class TaxRate {
4 |
5 | private final String name;
6 | private final Double rate;
7 |
8 | public TaxRate(String name, Double rate) {
9 | this.name = name;
10 | this.rate = rate;
11 | }
12 |
13 | public String getName() {
14 | return name;
15 | }
16 |
17 | public Double getRate() {
18 | return rate;
19 | }
20 |
21 | @Override
22 | public String toString() {
23 | return "{ \"name\":" + name + ", \"rate\" : " + rate + "}";
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/com/mycompany/app/servlets/DatabaseServlet.java:
--------------------------------------------------------------------------------
1 | package com.mycompany.app.servlets;
2 |
3 | import com.mycompany.app.util.MyProperties;
4 | import com.zaxxer.hikari.HikariConfig;
5 | import com.zaxxer.hikari.HikariDataSource;
6 | import jakarta.servlet.http.HttpServlet;
7 | import jakarta.servlet.http.HttpServletRequest;
8 | import jakarta.servlet.http.HttpServletResponse;
9 |
10 | import java.io.IOException;
11 | import java.sql.Connection;
12 | import java.sql.PreparedStatement;
13 | import java.sql.ResultSet;
14 | import java.sql.SQLException;
15 |
16 | public class DatabaseServlet extends HttpServlet {
17 |
18 | private HikariDataSource ds;
19 |
20 | static final String sql = "SELECT JSON_ARRAYAGG(JSON_OBJECT('name', name, 'id', id)) as result from tax_rates";
21 |
22 | @Override
23 | public void init() {
24 | ds = createConnectionPool();
25 | }
26 |
27 | @Override
28 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
29 | resp.setContentType("application/json");
30 |
31 | try (Connection connection = ds.getConnection();
32 | PreparedStatement statement = connection.prepareStatement(sql)) {
33 | ResultSet resultSet = statement.executeQuery();
34 |
35 | while (resultSet.next()) {
36 | resultSet.getBinaryStream("result")
37 | .transferTo(resp.getOutputStream());
38 | }
39 |
40 | } catch (SQLException e) {
41 | e.printStackTrace();
42 | }
43 | }
44 |
45 |
46 | private HikariDataSource createConnectionPool() {
47 | HikariConfig config = new HikariConfig();
48 | final String hikariSize_ = MyProperties.INSTANCE.getProperty("hikari.size");
49 | if (hikariSize_ != null) {
50 | final Integer hikariSize = Integer.valueOf(hikariSize_);
51 |
52 | System.out.println("Setting HikariCP to " + hikariSize + " connections");
53 | config.setMinimumIdle(hikariSize);
54 | config.setMaximumPoolSize(hikariSize);
55 | }
56 | config.setJdbcUrl(MyProperties.INSTANCE.getProperty("jdbc.url"));
57 | config.setUsername(MyProperties.INSTANCE.getProperty("jdbc.user"));
58 | config.setPassword(MyProperties.INSTANCE.getProperty("jdbc.password"));
59 | config.addDataSourceProperty("cachePrepStmts", "true");
60 | config.addDataSourceProperty("prepStmtCacheSize", "250");
61 | config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");
62 | config.addDataSourceProperty("useServerPrepStmts","true");
63 | config.addDataSourceProperty("useLocalSessionState","true");
64 | config.addDataSourceProperty("rewriteBatchedStatements","true");
65 | config.addDataSourceProperty("cacheResultSetMetadata","true");
66 | config.addDataSourceProperty("cacheServerConfiguration","true");
67 | config.addDataSourceProperty("elideSetAutoCommits","true");
68 | config.addDataSourceProperty("maintainTimeStats", "false");
69 |
70 | return new HikariDataSource(config);
71 | }
72 |
73 | }
--------------------------------------------------------------------------------
/src/main/java/com/mycompany/app/servlets/PlainJavaServlet.java:
--------------------------------------------------------------------------------
1 | package com.mycompany.app.servlets;
2 |
3 | import com.mycompany.app.model.TaxRate;
4 | import jakarta.servlet.http.HttpServlet;
5 | import jakarta.servlet.http.HttpServletRequest;
6 | import jakarta.servlet.http.HttpServletResponse;
7 |
8 | import java.io.IOException;
9 | import java.security.SecureRandom;
10 |
11 |
12 | public class PlainJavaServlet extends HttpServlet {
13 |
14 | SecureRandom random = new SecureRandom();
15 |
16 | @Override
17 | protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
18 | final TaxRate rate = new TaxRate("German VAT", random.nextDouble());
19 |
20 | resp.setContentType("application/json");
21 | resp.getWriter().write(rate.toString());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/com/mycompany/app/util/MyProperties.java:
--------------------------------------------------------------------------------
1 | package com.mycompany.app.util;
2 |
3 | import com.mycompany.app.PerformanceTest;
4 |
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.nio.file.Files;
8 | import java.nio.file.Path;
9 | import java.nio.file.Paths;
10 | import java.util.Properties;
11 |
12 | public enum MyProperties {
13 |
14 | INSTANCE;
15 |
16 | private Properties properties = new Properties();
17 |
18 | MyProperties() {
19 | final Path propsFile = Paths.get("./application.properties");
20 | System.out.println("Curren Directory = " + Paths.get(".").normalize().toAbsolutePath().toString());
21 |
22 | if (Files.exists(propsFile)) {
23 | try (InputStream is = Files.newInputStream(propsFile)) {
24 | properties.load(is);
25 | } catch (IOException e) {
26 | e.printStackTrace();
27 | }
28 | } else {
29 | try (InputStream is = PerformanceTest.class.getResourceAsStream("/application.properties")) {
30 | properties.load(is);
31 | } catch (IOException e) {
32 | e.printStackTrace();
33 | }
34 | }
35 | }
36 |
37 | public Properties getProperties() {
38 | return properties;
39 | }
40 |
41 | public String getProperty(String key) {
42 | return (String) properties.get(key);
43 | }
44 | }
--------------------------------------------------------------------------------
/src/main/java/com/mycompany/app/util/UpdatePlot.java:
--------------------------------------------------------------------------------
1 | package com.mycompany.app.util;
2 |
3 | import com.mycompany.app.PerformanceTest;
4 |
5 | import java.io.IOException;
6 | import java.nio.file.Paths;
7 |
8 | public class UpdatePlot {
9 | public static void main(String[] args) throws IOException {
10 | PerformanceTest.updatePlot(Paths.get(".\\target\\results\\plot"));
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | jdbc.url=jdbc:mysql://yourRdsURL/marco
2 | jdbc.user=chooseYourOwn
3 | jdbc.password=chooseYourOwn
4 | hikari.size = 50
--------------------------------------------------------------------------------
/src/main/resources/database.sql:
--------------------------------------------------------------------------------
1 | create table tax_rates (id int auto_increment primary key not null, name varchar(255));
2 | insert into tax_rates (name) values ('DE VAT');
3 | insert into tax_rates (name) values ('UK VAT');
4 | insert into tax_rates (name) values ('FR VAT');
--------------------------------------------------------------------------------
/src/main/resources/plot_template.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
10 |
11 |
12 |
13 |
122 |
171 |
182 |
183 |
214 |
215 |
335 |
336 |
342 |
343 |
344 |
345 |
346 | HdrHistogram Plotter
347 |
348 |
349 |
350 | Please select file(s) above.
351 |
352 |
353 | None Loaded
354 |
355 | Latency time units:
356 |
357 | seconds
358 | milliseconds
359 | microseconds
360 | nanoseconds
361 |
362 | Export Image
363 |
364 |
365 |
366 | Percentile range:
367 |
368 |
372 | 99.99999%
373 |
383 |
384 |
385 |
386 | *** Note: Input files are expected to be in the .hgrm format produced by
387 | HistogramLogProcessor, or the percentile output format for HdrHistogram.
388 | See example file format
389 | here
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 | Value Percentile TotalCount 1/(1-Percentile)
415 |
416 | 2.759 0.000000000000 1 1.00
417 | 2.990 0.100000000000 10 1.11
418 | 3.056 0.200000000000 19 1.25
419 | 3.115 0.300000000000 31 1.43
420 | 3.164 0.400000000000 38 1.67
421 | 3.326 0.500000000000 47 2.00
422 | 3.977 0.550000000000 52 2.22
423 | 6.193 0.600000000000 57 2.50
424 | 21.889 0.650000000000 62 2.86
425 | 36.438 0.700000000000 66 3.33
426 | 68.551 0.750000000000 71 4.00
427 | 84.935 0.775000000000 73 4.44
428 | 102.760 0.800000000000 76 5.00
429 | 111.477 0.825000000000 78 5.71
430 | 122.618 0.850000000000 80 6.67
431 | 199.623 0.875000000000 83 8.00
432 | 200.802 0.887500000000 84 8.89
433 | 222.953 0.900000000000 85 10.00
434 | 258.474 0.912500000000 86 11.43
435 | 340.787 0.925000000000 87 13.33
436 | 410.518 0.937500000000 89 16.00
437 | 410.518 0.943750000000 89 17.78
438 | 433.324 0.950000000000 90 20.00
439 | 433.324 0.956250000000 90 22.86
440 | 448.528 0.962500000000 91 26.67
441 | 483.131 0.968750000000 92 32.00
442 | 483.131 0.971875000000 92 35.56
443 | 483.131 0.975000000000 92 40.00
444 | 483.131 0.978125000000 92 45.71
445 | 620.757 0.981250000000 93 53.33
446 | 620.757 0.984375000000 93 64.00
447 | 620.757 0.985937500000 93 71.11
448 | 620.757 0.987500000000 93 80.00
449 | 620.757 0.989062500000 93 91.43
450 | 904.397 0.990625000000 94 106.67
451 | 904.397 1.000000000000 94
452 | #[Mean = 72.069, StdDeviation = 150.578]
453 | #[Max = 904.397, Total count = 94]
454 | #[Buckets = 17, SubBuckets = 2048]
455 |
456 |
457 | Value Percentile TotalCount 1/(1-Percentile)
458 |
459 |
460 | 2.626 0.000000000000 1 1.00
461 | 2.689 0.100000000000 9 1.11
462 | 2.730 0.200000000000 18 1.25
463 | 2.753 0.300000000000 27 1.43
464 | 2.777 0.400000000000 36 1.67
465 | 2.804 0.500000000000 45 2.00
466 | 2.828 0.550000000000 49 2.22
467 | 2.845 0.600000000000 56 2.50
468 | 2.851 0.650000000000 60 2.86
469 | 2.879 0.700000000000 63 3.33
470 | 2.888 0.750000000000 67 4.00
471 | 2.894 0.775000000000 69 4.44
472 | 2.916 0.800000000000 72 5.00
473 | 2.970 0.825000000000 74 5.71
474 | 2.974 0.850000000000 77 6.67
475 | 2.984 0.875000000000 78 8.00
476 | 2.986 0.887500000000 79 8.89
477 | 3.006 0.900000000000 81 10.00
478 | 3.015 0.912500000000 82 11.43
479 | 3.017 0.925000000000 83 13.33
480 | 3.025 0.937500000000 84 16.00
481 | 3.025 0.943750000000 84 17.78
482 | 3.129 0.950000000000 85 20.00
483 | 3.164 0.956250000000 86 22.86
484 | 3.164 0.962500000000 86 26.67
485 | 3.250 0.968750000000 87 32.00
486 | 3.250 0.971875000000 87 35.56
487 | 3.250 0.975000000000 87 40.00
488 | 6.316 0.978125000000 88 45.71
489 | 6.316 0.981250000000 88 53.33
490 | 6.316 0.984375000000 88 64.00
491 | 6.316 0.985937500000 88 71.11
492 | 6.316 0.987500000000 88 80.00
493 | 98.304 0.989062500000 89 91.43
494 | 98.304 1.000000000000 89
495 | #[Mean = 3.936, StdDeviation = 10.064]
496 | #[Max = 98.304, Total count = 89]
497 | #[Buckets = 17, SubBuckets = 2048]
498 |
499 |
500 | Value Percentile TotalCount 1/(1-Percentile)
501 | 2.791 0.000000000000 1 1.00
502 | 2.810 0.100000000000 3 1.11
503 | 2.845 0.200000000000 6 1.25
504 | 2.867 0.300000000000 9 1.43
505 | 2.929 0.400000000000 12 1.67
506 | 2.951 0.500000000000 15 2.00
507 | 2.953 0.550000000000 16 2.22
508 | 2.968 0.600000000000 18 2.50
509 | 2.970 0.650000000000 19 2.86
510 | 3.013 0.700000000000 22 3.33
511 | 3.013 0.750000000000 22 4.00
512 | 3.029 0.775000000000 23 4.44
513 | 3.033 0.800000000000 24 5.00
514 | 3.033 0.825000000000 24 5.71
515 | 3.135 0.850000000000 25 6.67
516 | 3.176 0.875000000000 26 8.00
517 | 3.176 0.887500000000 26 8.89
518 | 3.242 0.900000000000 27 10.00
519 | 3.242 0.912500000000 27 11.43
520 | 3.242 0.925000000000 27 13.33
521 | 5.317 0.937500000000 28 16.00
522 | 5.317 0.943750000000 28 17.78
523 | 5.317 0.950000000000 28 20.00
524 | 5.317 0.956250000000 28 22.86
525 | 5.317 0.962500000000 28 26.67
526 | 90.309 0.968750000000 29 32.00
527 | 90.309 1.000000000000 29
528 | #[Mean = 6.037, StdDeviation = 15.926]
529 | #[Max = 90.309, Total count = 29]
530 | #[Buckets = 17, SubBuckets = 2048]
531 |
532 |
533 |
--------------------------------------------------------------------------------
/src/main/resources/simplelogger.properties:
--------------------------------------------------------------------------------
1 | org.slf4j.simpleLogger.logFile=System.out
2 | org.slf4j.simpleLogger.log=error
3 | org.slf4j.simpleLogger.log.org.apache=error
4 | org.slf4j.simpleLogger.log.com.mycompany=info
--------------------------------------------------------------------------------