Intent.putExtra 与 getJSONObject - Android
我对应用程序的性能有疑问。
我在外部数据库中有一个对象,并且我已经从数据库中提取了有关它的所有数据,包括唯一的 id。我开始一个新活动,但我想在新活动中对同一个对象使用相同的信息 - 这会更快 - 包括我已经通过 getJSONObject 获得的所有字符串作为意图的额外内容或仅包含对象的 id 作为 intent extra
并对数据库进行新查询,接收响应并再次获取 json 响应?
我如何测试哪种方法比另一种方法更快?
I have a question regarding the performance of an application.
I have an object in an external database and I have already extracted all the data about it from the database, including unique id. I start a new activity, but I want to use the same info for the same object in the new activity - what will be faster - include all the strings I already obtained via getJSONObject
as extras for the intent or include just the object's id as an intent extra
and make a new query to the database, receive the response and obtain the json response once again?
And how could I test what method is faster than the other?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
数据库查询是比仅传递意图中的字符串更昂贵的操作(特别是如果您传递 JSON 字符串本身,而不是其中的每个字符串),因此如果您要使用相同的数据,我认为您应该使用然而,其意图并不难以测试和衡量。
Database query is a more expensive action than just passing the strings in the intent (especially if you pass the JSON string itself, not each string inside it) so if you're going to use the same data, I think you should pass it with the intent, however, this is not something that is hard to test and measure.