Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Performance issue: drawCircles(context: CGContext) in LineChart #3798

Closed
Osolemio opened this issue Dec 23, 2018 · 5 comments
Closed

Performance issue: drawCircles(context: CGContext) in LineChart #3798

Osolemio opened this issue Dec 23, 2018 · 5 comments

Comments

@Osolemio
Copy link

Osolemio commented Dec 23, 2018

Hello, Daniel
I used MPAndroidCharts with very good performance for my LineCharts (a number of lines up to 40 000 and more points for each one). I'm very happy that you could migrate this library to iOS. Thank you very much.
I wonder why on iOS my charts rendering causes too long and heavy CPU load. So, rendering takes too much time comparing to MPAndroidCharts.

Under profiler I see that 100% eats drawCircles() /copy and release blocks/, despite being disabled and the circles are really not shown:

lineDataSets[i].drawCirclesEnabled = false lineDataSets[i].drawCircleHoleEnabled = false //added that just for case

default

So, I remember very well that if I enable drawCircles for big datasets on Android it's getting slow as I have here with "disabled" circles.

P.S.
private func drawCircles(context: CGContext) { return

saved me. All the heavy load (100%) now is on aa_render CoreGraphics. That's ok. The same chart rendering takes 2s. 20! times faster. Hehe ;)

@liuxuan30
Copy link
Member

I'm confused,

P.S.
private func drawCircles(context: CGContext) { return
saved me. All the heavy load (100%) now is on aa_render CoreGraphics. That's ok. The same chart rendering takes 2s. 20! times faster.

do you have issue now or solved?

@Osolemio
Copy link
Author

Osolemio commented Dec 24, 2018

I'm confused,
do you have issue now or solved?

The issue is still there. I have blocked non-disabling func drawCircles with 'return' in the beginning, because I don't need it in my package. The issue IMHO that it shouldn't been called when drawCirclesEnabled = false

@liuxuan30
Copy link
Member

liuxuan30 commented Dec 26, 2018

I'm not very sure what you mean, but I'm guessing you are saying that you don't need to draw circles, but drawCircles still get called and eat your CPU power?

I looked into the code,

                if !dataSet.isDrawCirclesEnabled
                {
                    continue
                }

is called inside drawCircles but seems can be moved up, is this what are you trying to say?

for instance, I can move it to

        for i in 0 ..< dataSets.count
        {
            guard let dataSet = lineData.getDataSetByIndex(i) as? ILineChartDataSet else { continue }
            
            if !dataSet.isVisible || dataSet.entryCount == 0  // <-- add !dataSet.isDrawCirclesEnabled here
            {
                continue
            }

So we can skip some code, can you try it out if it solves your perf issue?

@liuxuan30
Copy link
Member

seems we will fix this in #3164

@Osolemio
Copy link
Author

So we can skip some code, can you try it out if it solves your perf issue?

Yep, that's it. Can confirm. It fixes the issue. Moved it up in "if" statement.

Thank you! Have a nice day

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants