Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Till Roenneberg

macrumors newbie
Original poster
Aug 22, 2008
8
0
In my Cocoa application (not document based), I write a key-coded array to the disc and the method works perfectly. The only drawback is that it takes ages (OS 10.4.1). Granted, the file is 6 MB but should it really take several minutes? Any suggestions why this is so slow and how to make it faster?

Thanks,
Till


NSMutableDictionary *rootObject = [NSMutableDictionary dictionary];
[rootObject setValue: [here, I pass an NSMUtableArray created in the program]
forKey:mad:"channels"];
[NSKeyedArchiver archiveRootObject: rootObject toFile: path];
 

Sayer

macrumors 6502a
Jan 4, 2002
981
0
Austin, TX
Build a debug version and run and attach Shark to it to see where its spending so much time.

And, well, a 6 meg mutable array? Geeze. Write a custom data storage class or something. Ask Google, there's all kinds of stuff out there.
 

Till Roenneberg

macrumors newbie
Original poster
Aug 22, 2008
8
0
speed is compiling dependent

Thanks. I am new to Cocoa and I still have to learn a lot before writing a custom data storage class (BTW, I couldn't find anything obviously useful in Google under these key words).

I just realised that if I compile for powerPC, the save process is very fast but when I compile for intel, it becomes unbearably slow.
Any idea why?
 

JonnyThunder

macrumors member
Aug 16, 2008
67
0
I know that iPhone has SQLite ability built in, which would be perfect for this type of application - but I'm too new at Obj-C to know whether it's part of Cocoa or not. (if not, i'm sure you can find a library for it somewhere)
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
What sort of data are you saving? At 6Mb in size I am assuming it's binary data, not text. Images? Audio? Have you looked at using a package filetype instead (basically a directory that acts as a file). This is how Pages etc saves it's data. The advantage of this is that you can save the data in it's native format which should be quicker.
 

Till Roenneberg

macrumors newbie
Original poster
Aug 22, 2008
8
0
I am saving channels of experiments. They are custom classes that can hold a variety of data, times and values of time series, channel descriptions as text. Since I am displaying the channels and their content in a lot of windows, they have property lists so that they can easily be updated in tables. The files are dynamic, so that more channels can be added, more information can be added to existing channels (data types which are another custom class with properties). In future, there may be an extension to saving graphs with the channels but presently, it's only Arrays, Strings, and Properties.

Thanks Till
 

robbieduncan

Moderator emeritus
Jul 24, 2002
25,611
893
Harrogate
In that case it sounds like something in your code is causing the archiver to run very slowly for some reason. The above suggestion to profile in Shark is the best way forward: find out what the code is spending it's time doing and then try and fix that...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.