This project is archived and is in readonly mode.
DateTime#to_json is slow.
Reported by Alex Zepeda | July 10th, 2008 @ 07:34 PM | in 2.x
The DateTime#to_json method is extremely slow. Converting ~6700 AR objects (with two datetime fields each) to JSON takes roughly 18 seconds on a 2.2GHz Core 2 Duo machine.
This patch simplifies the code, avoiding excessive string operations. End result is about a 5x improvement (~18 to ~2 seconds).
Comments and changes to this ticket
-
Alex Zepeda July 10th, 2008 @ 07:34 PM
- Title changed from Time#to_json to Time#to_json is slow.
-
Cheah Chu Yeow July 11th, 2008 @ 03:06 AM
This looks good but it's slightly outdated because it's diffed against the old SVN version of Rails). Don't think Jeremy will have a problem with that though :)
-
Ripta Pasay July 12th, 2008 @ 10:25 PM
- Title changed from Time#to_json is slow. to DateTime#to_json is slow.
- Tag changed from 2.0-stable, activerecord, patch to 2.0-stable, activesupport, patch
Benchmarking the changes, I could only get about a 0.25% speed-up at best. I agree the string operation is unnecessary and there was a speed-up, but it seems negligible over a large number of iterations.
n = 100,000 user system total real original 62.240000 0.090000 62.330000 ( 62.431844) patched 62.090000 0.090000 62.180000 ( 62.276596)
Benchmark attached, in case I missed something.
-
Repository July 14th, 2008 @ 01:44 AM
(from [9783e66cade4d145389cca18fab822f44d03161a]) Slightly faster DateTime#to_json. [#598 state:resolved] [Alex Zepeda]
-
Pratik July 14th, 2008 @ 03:03 AM
- State changed from new to resolved
-
Repository August 25th, 2008 @ 09:27 AM
(from [50c73c2dfd0d5eb880426e7bc385bcee004ffe3e]) Slightly faster DateTime#to_json. [#598 state:resolved] [Alex Zepeda] http://github.com/rails/rails/co...
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>
People watching this ticket
Attachments
Tags
Referenced by
- 598 DateTime#to_json is slow. (from [50c73c2dfd0d5eb880426e7bc385bcee004ffe3e]) Slightl...