核心数据 - 我可以将计算值存储为持久属性吗?
背景
- 我有一个计算值存储在瞬态属性中。
- 每次我的应用程序启动时,瞬态都需要更新。
- 启动时间确实很慢(即10-15秒)
- Instruments确认更新非常昂贵。
问题
可以将计算值存储在持久属性中吗?
我将使用 Martin Brugger 的从属属性 来保持计算值最新。
更多信息
我的计算值是数千个对象的持续时间:
Name Duration
Users 70s
Proposal.doc 35s
12:32-12:32 5s
13:11-13:11 30s
Proposal2.doc 35s
14:32-14:32 15s
15:11-15:11 20s
...thousands more objects...
我尝试过的
我已经使用预取和
setReturnsObjectsAsFaults:NO
最大限度地减少了触发的故障数量,但它使用了负载的内存,但仍然需要很长时间。我已经使我的瞬态更新代码尽可能高效。
我知道我可以在后台线程上获取并使用进度条,但我希望用户根本不必等待。
Background
- I have a calculated value stored in a transient attribute.
- Every time my app starts up, the transient needs to be updated.
- Startup time is really slow (i.e. 10-15 seconds)
- Instruments confirms the update is very expensive.
Question
Is it OK to store a calculated value in a persistent attribute?
I'd use Martin Brugger's Dependant Properties to keep the calculated value up to date.
More Information
My calculated value is the duration on thousands of objects:
Name Duration
Users 70s
Proposal.doc 35s
12:32-12:32 5s
13:11-13:11 30s
Proposal2.doc 35s
14:32-14:32 15s
15:11-15:11 20s
...thousands more objects...
What I've Tried
I've minimised the number of faults that are firing, using prefetching and
setReturnsObjectsAsFaults:NO
but it uses loads of memory and still takes ages.I've made my transient updating code as efficient as I know how.
I know I could fetch on a background thread and use a progress bar, but I'd prefer the user to not have to wait at all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定我是否完全理解这个问题,但我认为您所问的问题的简单答案是“当然”。 :-)
拥有瞬态、实时计算的“currentTotalDuration”值和“cachedTotalDuration”属性没有任何问题。当“currentTotalDuration”更新后,扔到“cachedTotalDuration”中就完成了。对我来说,拥有一个持久缓存属性和一个仅在需要更新时才使用的“实时计算”瞬态值听起来完全合理。
我不熟悉 Martin Brugger 的从属属性,但听起来大部分艰苦的工作已经为您完成了。
我希望我回答了您实际提出的问题。 :-D
I'm not sure I fully understand the question, but the simple answer to what I think you're asking is "of course." :-)
There's nothing wrong at all with having a transient, real-time computed "currentTotalDuration" value and a "cachedTotalDuration" attribute. When "currentTotalDuration" is updated, throw it into "cachedTotalDuration" and it's done. It sounds perfectly reasonable to me to have a persistent cached attribute alongside a "live-computed" transient value that's only used when it needs to be updated.
I'm not familiar with Martin Brugger's Dependant Properties, but it sounds like most of the hard work is already done for you.
I hope I answered the question you actually asked. :-D