4
$\begingroup$

I occasionally end up with a notebook that is excessively slow in the front-end because of its size. Often it's some animation. How can I use Mathematica to find the large cell responsible for this?

Here's an example notebook where I ended up with this problem.

$\endgroup$
3
  • 1
    $\begingroup$ maybe something like ReverseSortBy[Cells[EvaluationNotebook[], GeneratedCell -> True], ByteCount@NotebookRead@# &]? $\endgroup$
    – kglr
    Nov 19, 2023 at 2:01
  • $\begingroup$ You could try using ``ResourceFunction["NotebookCellData"][]` $\endgroup$
    – Carl Woll
    Nov 21, 2023 at 17:15
  • $\begingroup$ Related question: Notebook cells space on disk profiler $\endgroup$ Nov 23, 2023 at 3:11

2 Answers 2

1
$\begingroup$

Maybe something like:

Map[Tooltip[#, ByteCount@NotebookRead@#] &] @
 TakeLargestBy[Cells[EvaluationNotebook[], GeneratedCell -> True], 
  ByteCount @ NotebookRead @ # &, 10]

enter image description here

Click on the button to go the target cell.

$\endgroup$
2
$\begingroup$

NotebookCellData gives a slightly nicer formatted table. Looks like a single vector graphics can push 50MB, makes sense to Rasterize.

notebookCellData = 
  ResourceFunction["NotebookCellData", 
   ResourceSystemBase -> 
    "https://www.wolframcloud.com/obj/resourcesystem/api/1.0"];
Take[ReverseSortBy[
  notebookCellData[
   EvaluationNotebook[], {"CellByteCount"}], #CellByteCount &], 
 UpTo[5]]

enter image description here

$\endgroup$

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .