https://bz.apache.org/bugzilla/show_bug.cgi?id=61040
--- Comment #2 from [email protected] --- I always hesitate to the implementation for the duration to add. Either I use the regex and implement our own format ( with months, days, minutes, seconds and even more like weeks etc..) or I use the Java 8 implementation with Duration object. I made a micro bench like this : Collection<CompoundVariable> params = makeParams("YYYY-MM-dd'T'HH:mm:ss", "", "P10DT-1H-5M5S", ""); long start = System.nanoTime(); for (int i = 0; i < 100_000; i++) { function.setParameters(params); value = function.execute(result, null); } long elapsed = System.nanoTime() - start; params = makeParams("YYYY-MM-dd'T'HH:mm:ss", "", "+10d-1H-5m5s", ""); start = System.nanoTime(); for (int i = 0; i < 100_000; i++) { function2.setParameters(params); value = function2.execute(result, null); } long elapsed2 = System.nanoTime() - start; System.out.println("Duration implementation : " + elapsed + " nanosecond"); System.out.println("Regex implementation : " + elapsed2 + " nanosecond"); With 100_000 calls result are : Duration implementation : 536599024 nanosecond Regex implementation : 283168954 nanosecond With 1_000_000 calls : Duration implementation : 1915462780 nanosecond Regex implementation : 1687908387 nanosecond With 10_000_000 calls : Duration implementation : 16609113426 nanosecond Regex implementation : 16680832427 nanosecond With 100_000_000 calls : Duration implementation : 150074506145 nanosecond Regex implementation : 164859380430 nanosecond So about 10_000_000 calls, the Duration implementation start to be better in performance. For me, I prefere the Regex implementation, which is more flexible and easy to understand for a user. What is your opinion? -- You are receiving this mail because: You are the assignee for the bug.
