TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

The performance of .to_json in Rails sucks

11 点作者 kranzky超过 12 年前

2 条评论

threedaymonk超过 12 年前
I'm torn. On one hand, yes, this is unsatisfactorily slow.<p>On the other, all my experience has taught me that making objects (especially in the case of ActiveRecord objects that are mapped to database tables) directly responsible for their API serialisation leads to pain: those objects end up bloated, the API reflects internal concerns rather than usage patterns, and it's really hard to evolve the API or to provide multiple versions simultaneously.<p>So even though .to_json sucks, I'm far from convinced that it matters. I'd fix it by taking it out entirely!
评论 #5191063 未加载
dragonwriter超过 12 年前
How is "and there's nothing you can do" true? The article clearly describes how the author solved the problem in the context of their app, which is a generally applicable solution (that is, applying the same kind of fix that active support did that caused the problem, but using a higher-performance JSON solution than the one active_support hacked in to fix the original bug whose fix caused the poor performance.)
评论 #5188787 未加载