I had a look at the code and it is not exactly what I had in mind for the 
measurements.  The problem with your measurements is that the canvas is 
re-drawn only when needed, so the time between two calls to on-paint is not 
relevant for performance measurements.

For the on-paint, the time of the draw itself needs to be measured:

(define/override (on-paint)
  (define begin-timestamp (current-inexact-milliseconds))
  (super on-paint)
  (define end-timestamp (current-inexact-milliseconds))
  (set! paint-event-stats
        (update-statistics paint-event-stats (- end-timestamp begin-
timestamp))))

For the mouse event, the time between when the event is created and the 
time it is passed to the callback:

(define ((make-current-value-renderer fn) snip event x y)
  (define delta (- (current-inexact-milliseconds) (send event get-time-stamp
)))
  (set! mouse-event-stats (update-statistics mouse-event-stats delta))
  (define overlays
    (and x y (eq? (send event get-event-type) 'motion)
         (list (vrule x #:style 'long-dash)
               (point-label (vector x (fn x)) #:anchor 'auto))))
  (send snip set-overlay-renderers overlays))


Alex.

On Wednesday, June 5, 2019 at 8:06:26 PM UTC+8, evdubs wrote:
>
> Thanks for responding, Alex.
>
> Here's what I came up with <http://pasterack.org/pastes/893> that I think 
> satisfies your recommendations. It shows the sin() plot, expects 
> interaction for 10 seconds, then prints min/max/mean/std dev for both the 
> mouse-event-callback for the snip and on-paint for the editor-canvas%.
>
> Here's the output from running that with Racket 7.2 and Racket 7.3.0.4:
>
> $ ./racket-7.2/bin/racket ~/Code/racket/chart-lag-test.rkt 
> Mouse
> Min: 1.115966796875
> Max: 1209.123046875
> Mean: 40.23961775104986
> StdDev: 81.88591520019294
>
> Paint
> Min: 3.35302734375
> Max: 275.579833984375
> Mean: 79.6534423828125
> StdDev: 113.45367443728956
>
> $ ./racket-7.3.0.4/bin/racket ~/Code/racket/chart-lag-test.rkt 
> Mouse
> Min: 1.072021484375
> Max: 1095.2412109375
> Mean: 21.93592705160883
> StdDev: 54.53777963909044
>
> Paint
> Min: 3.18798828125
> Max: 284.447998046875
> Mean: 80.8831787109375
> StdDev: 117.90272049413493
>
> These numbers seem to suggest that 7.3 is an improvement, at least from 
> the mouse-event stats, even though that is counter to the experience from 
> interacting with the plot. Have any other ideas?
>
> Evan
>
> On Tuesday, June 4, 2019 at 1:39:49 PM UTC-10, Alex Harsanyi wrote:
>>
>>
>>
>> On Tuesday, June 4, 2019 at 11:32:42 AM UTC+8, evdubs wrote:
>>>
>>> Thanks for trying it out.
>>>
>>> I just tried using the bash installer from 
>>> https://download.racket-lang.org/ and I experience the same issue of 
>>> lagginess in 7.3. I also tried using a snapshot release from 
>>> https://plt.eecs.northwestern.edu/snapshots/ and I experienced the same 
>>> issue. 
>>>
>>> I am not sure what I should try next other than maybe profiling, but I 
>>> have not had much luck making effective use of the profiler in the past for 
>>> interactive applications.
>>>
>>
>> Here are a few things you can try:
>>
>> First, check again whether there’s a performance drop in Racket 7.2 too 
>> -- you
>> don’t want to spend time tracking down a Racket problem only to find out 
>> that
>> the latest Ubuntu update disabled the hardware acceleration on the 
>> graphics
>> card.
>>
>> If it is indeed a regression in Racket 7.3, you can try narrowing the 
>> problem
>> down to either rendering or mouse event delays:
>>
>> * you can measure the time it takes to render the plot by measuring the 
>> time
>>   the paint method of the `editor-canvas%`. You will need to create a 
>> custom
>>   `editor-canvas%` and override `on-paint` and use
>>   `current-inexact-milliseconds` to measure the time.
>>
>> * to check if mouse events are delivered too late to the callback. You 
>> can use
>>   the `get-time-stamp` method on the event and compare it against
>>   `current-inexact-milliseconds` to determine the delay.
>>
>> You will need to compare both values against Racket 7.2 to see which one 
>> is
>> causing the slow down.
>>
>> Alex.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/a21321c2-372f-45bf-806f-ec07344986f1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to