pihentagy
2021-3-29 14:09:07

There was a patch for slow in-connections IIRC https://github.com/racket/racket/pull/3599 Is it possible that it is not shipped with racket8.0?


pihentagy
2021-3-29 14:09:45

samth
2021-3-29 14:18:05

That definitely appeared in 8.0; see the tag mentioned on https://github.com/racket/racket/commit/6ace62a717ace50acb7b7ff7e3e63f80192ed27b


pihentagy
2021-3-29 14:26:46

But it’s still embarrassingly slow


samth
2021-3-29 14:27:28

Can you time the individual lines in python?


samth
2021-3-29 14:27:39

My suspicion is you’re just seeing startup in for Racket


pihentagy
2021-3-29 14:29:21

in python? or in racket?


ben.knoble
2021-3-29 14:31:06

FWIW, found-2020 is (define (found-2020 [l : (Listof Integer)]) : (U Integer False) (and (eq? 2020 (apply + l)) (apply * l))) The times reported includes reading the file in both languages, which might be a secondary concern. I would try to time only the relevant bits (python has a timeit module, IIRC). I would try to make the programs do exactly the same thing, and (someone correct me if I’m wrong) but maybe compiling the racket example ahead-of-time would make a difference?


ben.knoble
2021-3-29 14:31:17

IOW comparing times is hard


pihentagy
2021-3-29 14:32:21

I don’t intend to race the two languages, but this much difference is huge. So I should know how to avoid the startup lag in Racket


ben.knoble
2021-3-29 14:33:17

Right; I’m suppose in a convoluted way I’m suggesting part of the difference is Racket’s startup time, which is apples-and-oranges to python, maybe?


ben.knoble
2021-3-29 14:34:16

Not targeted at you specifically, but a good read: https://ericlippert.com/2012/12/17/performance-rant/


pihentagy
2021-3-29 14:35:55

yes, indeed, when I prepend a print “hello” to the start of the program it appears just 2 seconds after the start


pihentagy
2021-3-29 14:36:22

Is there a way to reduce/avoid the startup time


samth
2021-3-29 14:36:31

Since your program is in Typed Racket, that’s mostly typechecking time


samth
2021-3-29 14:36:52

you can reduce it by running raco make <whatever>.rkt


samth
2021-3-29 14:37:05

But that will not reduce it to the level of Python


samth
2021-3-29 14:37:43

But it should make you happier


pihentagy
2021-3-29 14:45:47

so: I should explicitly call raco to create bytecode (unlike eg. python)


pihentagy
2021-3-29 14:48:24

and yes, even with bytecode available it’s above 0.8s


samth
2021-3-29 14:49:29

yes, macro expansion and compilation are both slower than in python


samth
2021-3-29 14:50:06

and also, the standard library is mostly in Racket so it takes longer to load


samth
2021-3-29 14:50:21

and also you’re using typed/racket which loads a bunch more code


samth
2021-3-29 14:50:46

and racket’s module loading semantics imply more load-time cost than Python (I think)


pihentagy
2021-3-29 14:51:45

So does typed/racket effects runtime performance and not just a compile-time checker?


samth
2021-3-29 14:54:09

Typed Racket affects runtime performance in two ways: 1. startup time code (Typed Racket is code that has to be loaded at startup because that’s how languages in Racket work, it’s a lot of code because that’s life) 2. contract checks: if you use require/typed or provide values to untyped clients


badkins
2021-3-29 15:07:47

@pihentagy if your use case involves needing to run many short scripts, one way to avoid the startup lag is to start Racket once, and then have it accept commands from standard input. Scripting languages like Python & Ruby will probably always have an edge re: startup lag.


yoeskastyle
2021-3-29 20:20:44

@yoeskastyle has joined the channel


yoeskastyle
2021-3-29 20:30:13

Can someone help me with this


yoeskastyle
2021-3-29 20:30:17

Determine the perimeter of each of the figures present in a list of points, and for each one of them save it as data, with an identifier or name, the perimeter and the set of points that make up the figure.


yoeskastyle
2021-3-29 20:31:01

I have to draw in scheme, but I really don’t know how


soegaard2
2021-3-29 20:33:09

Which book are you following?


yoeskastyle
2021-3-29 20:36:14

can be draw.rkt or htdp / image


soegaard2
2021-3-29 20:37:21

Yes - but what book are you following?


soegaard2
2021-3-29 20:38:35

A SICP style solution will look different from an HTDP style one.


yoeskastyle
2021-3-29 21:00:33

I did not understand your question very well, but the language in which I have to do it is scheme in drracket, to do the exercise I have to do it with draw.rkt maybe this https://docs.racket-lang.org/teachpack/draw.html


soegaard2
2021-3-29 21:48:25

petchar
2021-3-30 01:51:04

@petchar has joined the channel