<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Thank you very much for your email.<br>I'll try to adjust my code, and accept your suggestions.<br>"The question is: do all the lines you draw with cairo pass<br>>
through the bounding box?"<br>YES. Every line I draw has to be visible. The preprocessing goes through<br>the input coordinates, determines min/max and prepares appropriate bounding<br>box. Having said that, is applying your suggestions going to be reasonable in<br>terms of the speedup?<br><br>I really appreciate your help.<br><br>> Date: Tue, 31 Aug 2010 16:21:20 +0200<br>> Subject: Re: [cairo] Very large number of lines<br>> From: ranma42@gmail.com<br>> To: opustenom@hotmail.com<br>> CC: cairo@cairographics.org<br>> <br>> On Tue, Aug 31, 2010 at 2:51 PM, necko necko <opustenom@hotmail.com> wrote:<br>> > Thanks for the email.<br>> > You were right about stroke the same line over itself. Therefore, I made a simple<br>> > random coordinate generator that should more closely describe the problem<br>> > I'm working on.<br>> > Note that all the lines need to be shown in the pdf file (therefore I use translate<br>> > which depends on min/max coordinate). The number of lines is from<br>> > 20million-350million. This is the main reason I'm striving for speed (in<br>> > processing and in displaying).<br>> > Therefore, displaying a PNG file would be appropriate. Please consider the<br>> > code below.<br>> > The first translate option cairo_translate (cr, -229770, 26573); leads to<br>> > execution time<br>> > of around 7min, while the second one cairo_translate (cr, -429000, 35000);<br>> > leads to<br>> > execution time of around 1min. Is it because the invisible parts are not<br>> > processed?<br>> <br>> Invisible parts are faster than visible ones because they don't have to<br>> be composited, but they require some processing (to determine visibility).<br>> If your random data actually resembles your true data, consider a<br>> simple clipping function.<br>> In my attachment I get a big speedup when declaring NO_CLIP 0.<br>> (It does just "trivial" clipping, lines completely above/under/right/left of the<br>> visible region are not drawn, but there are some more lines that don't<br>> pass through it<br>> yet are not clipped with this check)<br>> <br>> ><br>> > For my application, everything within the bounding box (determined by the<br>> > min/max coordinate) should be displayed.<br>> <br>> That is obvious. The question is: do all the lines you draw with cairo pass<br>> through the bounding box?<br>> <br>> > I noted that the output is different when stroke() every 1000th or 100000th<br>> > line.<br>> > I thought this was because of the random number generator, but I tested it<br>> > several times.<br>> <br>> Don't use a variable seed. Stroking will be different because of compositing,<br>> but the differences in your attachments cannot be explained this way.<br>> Check again your output, making sure that you do not change anything else.<br>> (Doing the same in my attachment I cannot reproduce your problem)<br>> <br>> I tried to do minimum changes to your original file, but I couldn't<br>> resist changing<br>> the output.<br>> Please play around a little with the defines in the file. You will see that:<br>> - disabling clipping times get much slower<br>> - rendering to pdf is not as crazy as before, since only a few thousands lines<br>> are actually in the bbox (about the 0.5%)<br>> - higher ITER_NOs are possible in reasonable amounts of time (image should<br>> scale linearly, pdf worsen when you start swapping)<br>> <br>> Andrea<br>                                            </body>
</html>