mathematica-autobackup
mathematica-autobackup copied to clipboard
Too slow in recent Mathematica 11
This seems to work MUCH slower than the ordinary "Save" button in Mathematica 11. I do not know, why. Probably, some other saving command should be used in the script. Thanks, Sergey
Bummer! Sadly this was written in a much older version of Mathematica (7?) and hasn't been updated... If you can figure out an improvement please send a PR!
Well, it's probably not the problem of Mathematica version. It's a problem that Export works very slowly on some large files, while NotebookSave works fast. On the other hand, we do not want to use NotebookSave. So, I am not sure how to improve.
On 04/01/17 16:08, Josh Burkart wrote:
Bummer! Sadly this was written in a much older version of Mathematica (7?) and hasn't been updated... If you can figure out an improvement please send a PR!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/joshburkart/mathematica-autobackup/issues/1#issuecomment-270409784, or mute the thread https://github.com/notifications/unsubscribe-auth/ADTdBtKsjcyQBYClSLn0fLtClei0GEuSks5rO8QPgaJpZM4LaxQO.
Ah, actually, I remember noticing the speed difference too. Yep I'm not sure how to work around this either, other than by using smaller notebooks... Sorry!
I have experienced this too. It is prominent in notebooks with lots of large images. This makes the FrontEnd hang for quite some time after evaluations when the timeout for the auto-save has been reached again.
Is there really no way to fix this? Why should we not use NotebookSave?
I applied the following changes:
BackupName[file_String, num_Integer] :=
file <> StringJoin @@ Table["~", {num}] <> ".nb";
Monitor[
NotebookSave[EvaluationNotebook[], Print@bakfile;bakfile];
(*Print@renameFile[bakfile<>".nb",bakfile];(*HACKFIX for NotebookSave adding .nb to .nb~*)*)
NotebookSave[EvaluationNotebook[], nbfile];(*HACKFIX for restoring the actual name instead of changing it*)
(*Export[bakfile, EvaluationNotebook[], "NB"]*)
,
"Backing up " <> FileNameTake[nbfile] <> " to " <> FileNameTake[bakfile] <> "..."];
I had some trouble with RenameFile failing and NotebookSave adding .nb, but this works and seems much faster. This seems to do what I want.
Someone should report to WRI the NotebookSave <-> Export performance discrepancy.
@Masterxilo Thanks for looking into this! My recollection was that using NotebookSave actually changes the location that Mathematica thinks the notebook is located, so that the next time the user clicks File -> Save it updates the backup rather than the original save location. Maybe I'm wrong though?
I believe the issue is that Export doesn't support incremental updates, and always resaves the whole thing, whereas NotebookSave only saves the new stuff. Again could be wrong.
If your solution works with no deleterious side effects then please consider sending a PR!
Oh sorry, I see now that you got around this. Well in that case looks good to me! The slowness of using Export was always annoying to me too. PR?
Sure!
I would prefer to get .nb~ and .nb~~ files though.
With my fix I get .nb~.nb and .nb~~.nb files which mix with the normal notebooks. I find that not too pretty.
Ahh, yeah. Also, does this mean every time there's a backup, the notebook also gets saved? To its normal save path?
Yes. This might be problematic if the notebook becomes corrupted (making the original and the backup unusable on the next backup).