|
2008 03 31
|
TokyoCabinet
A TokyoCabinet binding was recently added. Here are the results for the performance test run on a first generation MacBook Pro.
287265 group transactional writes per second
166683 reads per second
118523 cursor reads per second
374672 group transactional removes per second
13654 individual transactional writes per second
14484 individual transactional removes per second
This test was in B-Tree mode and for reads and write the number of keys was 10,000, the key size is 22 bytes and the value size is 8 bytes. Order is random except for cursor reads, which are sequential.
Note: those "transactions" must be syncing to the OS buffers and not the disk.
|
|
2008 02 27
|
Screenshot
Some sample code for taking a screenshot in an OpenGL app:
First, let us add a Image method to help:
Image grabScreen := method(
data := Sequence clone
width := glutGet(GLUT_WINDOW_WIDTH)
height := glutGet(GLUT_WINDOW_HEIGHT)
glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, data)
self setDataWidthHeightComponentCount(data, width, height, 4)
self flipY
)
Now we can use it (within a running GL application):
Image clone grabScreen save("screenshot.jpg")
|
|
2008 01 09
|
Constants
Kevin Greer posted this to LtU recently and I though it was worth repeating due to the recent interest in dynamic features:
Constant := Object clone do (
with := method(msg,
self msg := msg
self activate := method(call message setName(msg asString); msg)
)
)
// Lets try it out: Make PI a regular number
PI := 3.1415926
// Make b a method that uses it
b := method(PI+PI)
writeln(b) // -> 6.283185
// Inspect bs "source" code
writeln(getSlot("b") code) // -> block(PI +(PI))
// Make PI a constant
PI := Constant with(3.1415926)
writeln(b) // -> 6.283185
writeln(getSlot("b") code) // -> block(3.141593 +(3.141593))
// Still works but when we look at the code of b we see that
// the PIs have been replaced with PIs value!!!
|