Re: [racket-users] DrRacket 6.5 + OS X El Capitan = slow execution

2016-08-16 Thread Ivan Kuzmin
Hello, Robby! Thank you for your reply.

I have done quoting out register-collecting-blit and the flashing gc icon 
disappeared. But the feeling of slowness is still present, I afraid.

I am timing execution with cursor blinks: it blinks once or twice in DrRacket 
6.5 while (+ 1 1) execution, but in DrRacket 6.2.1 this code executes almost 
immediately.
But more complex expressions aren’t executed proportionally slower - the same 
one blink.

P.S. May be it is just some strange cognitive effect. Is there a way to measure 
time from run button pressing to printing execution results precisely and 
objectively somehow?

> On 16 Aug 2016, at 02:52, Robby Findler  wrote:
> 
> Hi Ivan: here is another experiment to try. What happens if you follow
> these steps:
> 
> - start DrRacket
> - open "Language" menu's "Choose Language..." menu item
> - select "The Racket Language" (click ok to close the dialog)
> - select the "File" menu's "Open Require Path..." menu item
> - type "fr/pr/frame" in the dialog and hit return
> - search for "(register-c" in that file. You should see a call to
> register-collecting-blit around line 912 or so
> - put a quote in front of it (to stop it from executing), the code
> should be like this:
> 
>  '(register-collecting-blit gc-canvas
>0 0
>(send onb get-width)
>(send onb get-height)
>onb offb)
> 
> - save the file and restart DrRacket
> 
> At this point, redo your experiment that was very slow earlier (you
> may need to switch back to one of the teaching languages in the
> "Choose Language..." dialog to fully replicate your experiment).
> 
> If the steps above worked, you will have disabled the flashing gc
> icon, so if you were using that to time your DrRacket, then use
> something else (a watch, maybe).
> 
> Thanks in advance!
> 
> Robby

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: HtDP 2e

2016-08-16 Thread Luis Sanjuán
Ohne hast aber ohne rast;-) Congratulations and thanks for this great work! 
Hope HtDC is the next huge step.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] DrRacket 6.5 + OS X El Capitan = slow execution

2016-08-16 Thread Matthew Flatt
Do you see any change if you start DrRacket in Terminal with

  env PLT_INCREMENTAL_GC=n /Applications/Racket\ v6.5/bin/drracket 

? (That's assuming that Racket is installed as "Racket v6.5" in the
"Applications" folder.)

As of v6.4, DrRacket uses an incremental GC mode to reduce pauses while
programs are being edited. Incremental mode can slow down bulk work,
though, such as starting a program. The GC's mode adapts to the current
workload, but adapting takes a little while, and running a program
right after typing is one of the transition cases. In contrast,
clicking the "Run" button repeatedly should shift to a non-incremental
mode after a couple of clicks.

Thanks!
Matthew

At Tue, 16 Aug 2016 18:16:13 +1000, Ivan Kuzmin wrote:
> Hello, Robby! Thank you for your reply.
> 
> I have done quoting out register-collecting-blit and the flashing gc icon 
> disappeared. But the feeling of slowness is still present, I afraid.
> 
> I am timing execution with cursor blinks: it blinks once or twice in DrRacket 
> 6.5 while (+ 1 1) execution, but in DrRacket 6.2.1 this code executes almost 
> immediately.
> But more complex expressions aren’t executed proportionally slower - the same 
> one blink.
> 
> P.S. May be it is just some strange cognitive effect. Is there a way to 
> measure time from run button pressing to printing execution results precisely 
> and objectively somehow?
> 
> > On 16 Aug 2016, at 02:52, Robby Findler  wrote:
> > 
> > Hi Ivan: here is another experiment to try. What happens if you follow
> > these steps:
> > 
> > - start DrRacket
> > - open "Language" menu's "Choose Language..." menu item
> > - select "The Racket Language" (click ok to close the dialog)
> > - select the "File" menu's "Open Require Path..." menu item
> > - type "fr/pr/frame" in the dialog and hit return
> > - search for "(register-c" in that file. You should see a call to
> > register-collecting-blit around line 912 or so
> > - put a quote in front of it (to stop it from executing), the code
> > should be like this:
> > 
> >  '(register-collecting-blit gc-canvas
> >0 0
> >(send onb get-width)
> >(send onb get-height)
> >onb offb)
> > 
> > - save the file and restart DrRacket
> > 
> > At this point, redo your experiment that was very slow earlier (you
> > may need to switch back to one of the teaching languages in the
> > "Choose Language..." dialog to fully replicate your experiment).
> > 
> > If the steps above worked, you will have disabled the flashing gc
> > icon, so if you were using that to time your DrRacket, then use
> > something else (a watch, maybe).
> > 
> > Thanks in advance!
> > 
> > Robby

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] racket/db, creating queries from fetched values

2016-08-16 Thread ksiimson
Hi!

I'm a new user of Racket and I am trying to make a simple application which 
interfaces a MySQL database.

Fetching the data is quite straightforward, but I am having trouble coming up 
with a reasonable way to insert the data back into database. Basically the 
fetched vector contains many different data types, but I haven't found an easy 
way to serialize them back to a string for SQL queries.

  SELECT now();

Would result in a vector like this

  (vector (sql-timestamp 2016 8 16 17 1 39 0 #f))

What would be a reasonable way to serialize this to "2016-08-16 17:01:39", for 
example:

  INSERT INTO x VALUES ("2016-08-16 17:01:39")

This question is not particular to serializing a sql-timestamp, but any data 
type.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] DrRacket 6.5 + OS X El Capitan = slow execution

2016-08-16 Thread Robby Findler
On Tue, Aug 16, 2016 at 3:16 AM, Ivan Kuzmin  wrote:
> P.S. May be it is just some strange cognitive effect. Is there a way to 
> measure time from run button pressing to printing execution results precisely 
> and objectively somehow?

Probably it is real, but you're right that doing this a bit more
objectively is a good idea!

To do that, use the "Open Require Path..." menu item to open
"drracket/private/unit.rkt", search for these two lines:

  (define/public (execute-callback)
(when (send execute-button is-enabled?)

and add, just below them on its own line:

  (printf "Run: ~s\n" (current-process-milliseconds))

Then, using the same menu item to open "drracket/private/rep.rkt",
search for this line:

  (define/public (insert-prompt)

and insert just below it a similar line:

  (printf "Prompt: ~s\n" (current-process-milliseconds))

It should be the case that you'll be able to take two consecutive
printouts and use subtraction to get a good estimate of how much time
was used.

Thanks for your help looking into this!

Robby

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket/db, creating queries from fetched values

2016-08-16 Thread George Neuner

On 8/16/2016 10:04 AM, ksiimson wrote:

Hi!

I'm a new user of Racket and I am trying to make a simple application which 
interfaces a MySQL database.

Fetching the data is quite straightforward, but I am having trouble coming up 
with a reasonable way to insert the data back into database. Basically the 
fetched vector contains many different data types, but I haven't found an easy 
way to serialize them back to a string for SQL queries.

   SELECT now();

Would result in a vector like this

   (vector (sql-timestamp 2016 8 16 17 1 39 0 #f))

What would be a reasonable way to serialize this to "2016-08-16 17:01:39", for 
example:

   INSERT INTO x VALUES ("2016-08-16 17:01:39")

This question is not particular to serializing a sql-timestamp, but any data 
type.



You don't need to convert the values to text.  You want to use query 
parameters instead.


MySQL queries use "?" for parameter placeholders, so you want to do 
something like:


(query-exec dbc "INSERT INTO x ( a_datetime, an_integer, a_float ) 
VALUES (?,?,?)"

  "2016-08-16 17:01:39"
  42
  3.14159 )

The arguments to *query-exec* (or *query*, see below) need to match the 
order and expected types of the parameter placeholders in the query 
string, but you don't need to convert arguments to text or splice them 
into the string.  In general you don't want to do that anyway because 
that is how SQL injection flaws can creep into your code.  There are 
occasions when deficiencies in the SQL syntax actually will force you to 
splice things directly into the query string, but you should avoid doing 
so as much as possible.  Use query parameters unless you really have no 
choice.


If the argument type isn't correct you need to cast or convert it to the 
right type in the query string:  e.g., to pass a datetime to a query 
that expects just a date:


(define the-date  (sql-timestamp 2016 8 16 17 1 39 0 #f))
(query-exec dbc "INSERT INTO x ( a_datetime ) VALUES ( cast( ? as date ) )"
  the-date  )


Note: *query-exec* doesn't return status.  If you need to know how many 
rows were affected, use *query *instead.  For more information see

http://docs.racket-lang.org/db/query-api.html?q=query
http://docs.racket-lang.org/db/sql-types.html?q=mysql#%28part._mysql-types%29

Hope this helps,
George

--
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket/db, creating queries from fetched values

2016-08-16 Thread George Neuner


On 8/16/2016 12:33 PM, Kristjan Siimson wrote:


Ah, yes. I should of have clarified that I'm trying to build queries, 
but I don't want them to be executed. I guess, alternatively, I could 
solve it by creating a blackhole database and viewing the executed 
queries from the general log. If Im going with that approach, then 
this will help me to go in the right direction. Thanks for answering! :-)




Do you mean "prepared" queries?   Or something else?

Prepared queries are almost the same as parameterized:

(define stmt (prepare dbc  "INSERT INTO x VALUES( ?, ? )" ))

(bind-prepared-statement stmt   param-list  )
(query-exec dbc stmt )

(bind-prepared-statement stmt   another-param-list  )
(query-exec dbc stmt )


A prepared query is compiled once and the code is cached on the server 
for reuse until the connection is closed or the query is explicitly 
dropped.   The downside to this is that the prepared query uses a 
generic execution plan ... its parameters are not known at compile time 
so the query can't be optimized based on particular parameter values 
(which affects usage of auxiliary indexes).  Also be aware that prepared 
queries are tied to specific connections, so connection sharing/pooling 
may be problematic.  There also are server side limits on the number of 
prepared queries allowed - both per connection and globally.


Normal queries are compiled, executed and quickly discarded.  In reality 
the code is cached for a short time in case the *exact* same query 
(including parameter values) is submitted again.  The same query string 
paired with different parameters will be compiled as a new query.


George

--
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Linux packages?

2016-08-16 Thread Andreas Olsson
Would be great if it would be packages to download from racket-Lang. At least 
for the major dists. 

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Linux packages?

2016-08-16 Thread Hersh Krishna
On Tuesday, August 16, 2016 at 1:17:27 PM UTC-5, Andreas Olsson wrote:
> Would be great if it would be packages to download from racket-Lang. At least 
> for the major dists.

There's a PPA for ubuntu(https://launchpad.net/~plt/+archive/ubuntu/racket) 
which is how I got it. Maybe they could just put it on the downloads page?

-- 
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: Linux packages?

2016-08-16 Thread Andreas Olsson
If there was packages for the major dists like fedora, ubuntu and suse on the 
racket homepage it would be easier for people to get. It would help racket 
becoming a little more known and used.

-- 
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.
For more options, visit https://groups.google.com/d/optout.