Performance issue
See original GitHub issueI made a simple test where I draw multiple identical vertical lines from bottom to top in cycle. I found out that each new line renders much slower than previous one. Is it a bug or did I do something wrong?
def c(coord):
if isinstance(coord, (np.ndarray, list)) and len(coord) == 3:
return np.asarray(coord, dtype=np.float32) / 135
else:
return coord / 1.35
import numpy as np
from datetime import datetime
class mainScene(Scene):
CONFIG = {
"camera_config": {"background_color": '#ffffff'},
}
def construct(self):
for j in np.arange(-958.5, 960, 2):
start = datetime.now()
for _ in np.arange(-540, 540, 2):
line = Line(c([j, _, 0]), c([j, _+1, 0]), stroke_width=c(1), stroke_color='#000000')
self.add(line)
if _ == 538: print(int(j + 959.5), datetime.now() - start)
self.wait(.1)
1 0:00:00.389817
3 0:00:00.927884
5 0:00:01.458466
7 0:00:01.970841
9 0:00:02.500315
11 0:00:03.015520
13 0:00:03.712525
15 0:00:04.210232
17 0:00:04.822479
19 0:00:05.358658
21 0:00:06.160043
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Dealing with Performance Problems
Types of Performance Problems ; Quantity of work (untimely completion, limited production). Poor prioritizing, timing, scheduling; Lost time ; Quality of work ( ......
Read more >9 Examples of a Performance Issue - Simplicable Guide
A performance issue is a failure to meet the basic requirements of a job. They are based on reasonable expectations of behavior and...
Read more >Handling Performance Issues With Grace | Monster.com
Low Productivity or Late Completion – Make sure you've been clear about the requirements and expectations of the job. · Poor Quality of...
Read more >Top 5 Common Performance Problems - HRCI
Top 5 Common Performance Problems · Shallow Work · Inability to Prioritize · False Sense of Urgency · Productive Procrastination · Low-Quality Output....
Read more >5 Common Reasons for Performance Issues (Plus 3 Tips to ...
Most Common Causes of Performance Issues · 1. They lack knowledge or skill. · 2. They have unclear or unrealistic expectations. · 3....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
self.remove(mob1,mob2,...)
That is quite obvious if you think about how Manim should be working internally. Manim draws each object in each frame according to the preset order in the variable
self.mobjects
, as you already knowself.add (mob)
addsmob
toself.mobjects
. That means that the more mobjects added to the animation, more mobjects each frame will have to draw, for memory consumption. If you add 1000 mobjects withself.add
then in each frame the 1000 mobjects will have to be added according to the order ofself.mobjects
. There is no way around this because Manim was designed this way.This behavior is not similar to
self.play
, because the animated object is not successively added to memory. For example:In this animation there is only one
circle
object, and in the course of the animation no other mobject is added or removed, all objects inself.mobjects
remain intact,self.mobjects
is the same before and after the animation. There are some animations that can delete (FadeOut
, etc.) or add (FadeIn
,Write
,GrowFromCenter
, etc.) an object at the end, but they do not do it in large quantities as you intend to do so.Manim was not designed for such complex animations, Grant himself on his official website has said this, if Manim is not trained to do this I recommend using some other animation tool, such as Blender (in which you can also use Python 3).