Github user yjshen commented on the pull request:
https://github.com/apache/spark/pull/7870#issuecomment-127465398
I've updated the
[benchmark](https://gist.github.com/yjshen/2c48cfe6201a97e6e1f5):
To summarise:
1. Since it involves more unrelated calculation for `getDayOfMonth` and
`getMonth`, the current implementation have performance reduction in these
cases.
2. `dateAddMonth` and `monthBetween` enjoys performance improvement since
repeated evaluation of `getYearAndDayInYear` is eliminated in the current code.
3. When comparing our `DateTimeUtils` with `java.util.Calendar` for
`getDayOfMonth` and `getMonth`, the java version takes only ~1/2 or ~1/3
compared to `master` or `this PR`, showing out a quite charming possibility.
Note: I'm using `average time per operation this time`, smaller is better.
```
# Run complete. Total time: 00:03:26
Benchmark Mode Cnt Score Error Units
DateTimeUtilsBenchmark.dateAddMonth avgt 10 52.308 ± 6.216
ns/op
DateTimeUtilsBenchmark.dateAddMonthOld avgt 10 95.405 ± 5.761
ns/op
DateTimeUtilsBenchmark.getDayOfMonth avgt 10 31.663 ± 2.405
ns/op
DateTimeUtilsBenchmark.getDayOfMonthOld avgt 10 21.020 ± 3.467
ns/op
DateTimeUtilsBenchmark.getDayOfMonthJava avgt 10 13.505 ± 1.181
ns/op
DateTimeUtilsBenchmark.getMonth avgt 10 32.255 ± 2.362
ns/op
DateTimeUtilsBenchmark.getMonthOld avgt 10 18.594 ± 1.743
ns/op
DateTimeUtilsBenchmark.getMonthJava avgt 10 13.314 ± 0.897
ns/op
DateTimeUtilsBenchmark.monthBetween avgt 10 122.370 ± 16.001
ns/op
DateTimeUtilsBenchmark.monthBetweenOld avgt 10 148.683 ± 16.759
ns/op
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]