some further optimizations
parent
b57cdefde0
commit
a050578c3b
|
@ -2,7 +2,7 @@
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs bson.constants byte-arrays byte-vectors
|
USING: accessors assocs bson.constants byte-arrays byte-vectors
|
||||||
calendar fry io io.binary io.encodings io.encodings.string io.encodings.private
|
calendar fry io io.binary io.encodings io.encodings.string io.encodings.private
|
||||||
io.encodings.utf8 kernel math math.parser namespaces quotations
|
io.encodings.utf8.private io.encodings.utf8 kernel math math.parser namespaces quotations
|
||||||
sequences sequences.private serialize strings tools.walker words ;
|
sequences sequences.private serialize strings tools.walker words ;
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,13 @@ CONSTANT: INT64-SIZE 8
|
||||||
shared-buffer get
|
shared-buffer get
|
||||||
[ 8192 <byte-vector> [ shared-buffer set ] keep ] unless* ; inline
|
[ 8192 <byte-vector> [ shared-buffer set ] keep ] unless* ; inline
|
||||||
|
|
||||||
|
: >le-stream ( x n -- )
|
||||||
|
! >le write
|
||||||
|
swap '[ _ swap nth-byte 0 B{ 0 }
|
||||||
|
[ set-nth-unsafe ] keep write ] each
|
||||||
|
; inline
|
||||||
|
|
||||||
|
|
||||||
PRIVATE>
|
PRIVATE>
|
||||||
|
|
||||||
: reset-buffer ( buffer -- )
|
: reset-buffer ( buffer -- )
|
||||||
|
@ -74,12 +81,14 @@ M: objref bson-type? ( objref -- type ) drop T_Binary ;
|
||||||
M: quotation bson-type? ( quotation -- type ) drop T_Binary ;
|
M: quotation bson-type? ( quotation -- type ) drop T_Binary ;
|
||||||
M: byte-array bson-type? ( byte-array -- type ) drop T_Binary ;
|
M: byte-array bson-type? ( byte-array -- type ) drop T_Binary ;
|
||||||
|
|
||||||
: write-utf8-string ( string -- ) output-stream get utf8 encoder-write ; inline
|
: write-utf8-string ( string -- )
|
||||||
: write-byte ( byte -- ) CHAR-SIZE >le write ; inline
|
output-stream get '[ _ swap char>utf8 ] each ; inline
|
||||||
: write-int32 ( int -- ) INT32-SIZE >le write ; inline
|
|
||||||
: write-double ( real -- ) double>bits INT64-SIZE >le write ; inline
|
: write-byte ( byte -- ) CHAR-SIZE >le-stream ; inline
|
||||||
: write-cstring ( string -- ) write-utf8-string B{ 0 } write ; inline
|
: write-int32 ( int -- ) INT32-SIZE >le-stream ; inline
|
||||||
: write-longlong ( object -- ) INT64-SIZE >le write ; inline
|
: write-double ( real -- ) double>bits INT64-SIZE >le-stream ; inline
|
||||||
|
: write-cstring ( string -- ) write-utf8-string 0 write-byte ; inline
|
||||||
|
: write-longlong ( object -- ) INT64-SIZE >le-stream ; inline
|
||||||
|
|
||||||
: write-eoo ( -- ) T_EOO write-byte ; inline
|
: write-eoo ( -- ) T_EOO write-byte ; inline
|
||||||
: write-type ( obj -- obj ) [ bson-type? write-byte ] keep ; inline
|
: write-type ( obj -- obj ) [ bson-type? write-byte ] keep ; inline
|
||||||
|
|
|
@ -254,23 +254,23 @@ CONSTANT: DOC-LARGE H{ { "base_url" "http://www.example.com/test-me" }
|
||||||
|
|
||||||
: run-benchmarks ( -- )
|
: run-benchmarks ( -- )
|
||||||
"db" "db" get* "host" "127.0.0.1" get* "port" 27020 get* ensure-number <mdb>
|
"db" "db" get* "host" "127.0.0.1" get* "port" 27020 get* ensure-number <mdb>
|
||||||
[ ensure-buffer
|
[ ensure-buffer
|
||||||
print-header
|
print-header
|
||||||
! insert
|
! insert
|
||||||
! { small-doc-prepare medium-doc-prepare
|
{ small-doc-prepare medium-doc-prepare
|
||||||
{ large-doc-prepare }
|
large-doc-prepare }
|
||||||
{ { } { index } { errcheck } { index errcheck }
|
{ { } { index } { errcheck } { index errcheck }
|
||||||
{ batch } { batch errcheck } { batch index errcheck }
|
{ batch } { batch errcheck } { batch index errcheck }
|
||||||
} run-insert-bench
|
} run-insert-bench
|
||||||
! find-one
|
! find-one
|
||||||
! { small-doc medium-doc large-doc }
|
{ small-doc medium-doc large-doc }
|
||||||
! { { } { index } } run-find-one-bench
|
{ { } { index } } run-find-one-bench
|
||||||
! find-all
|
! find-all
|
||||||
! { small-doc medium-doc large-doc }
|
{ small-doc medium-doc large-doc }
|
||||||
! { { } { index } } run-find-all-bench
|
{ { } { index } } run-find-all-bench
|
||||||
! find-range
|
! find-range
|
||||||
! { small-doc medium-doc large-doc }
|
{ small-doc medium-doc large-doc }
|
||||||
! { { } { index } } run-find-range-bench
|
{ { } { index } } run-find-range-bench
|
||||||
] with-db ;
|
] with-db ;
|
||||||
|
|
||||||
MAIN: run-benchmarks
|
MAIN: run-benchmarks
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
USING: accessors assocs bson.reader bson.writer byte-arrays
|
USING: accessors assocs bson.reader bson.writer byte-arrays
|
||||||
byte-vectors combinators formatting fry io io.binary io.encodings.private
|
byte-vectors combinators formatting fry io io.binary io.encodings.private
|
||||||
io.encodings.binary io.encodings.string io.encodings.utf8 io.files
|
io.encodings.binary io.encodings.string io.encodings.utf8 io.encodings.utf8.private io.files
|
||||||
kernel locals math mongodb.msg namespaces sequences uuid ;
|
kernel locals math mongodb.msg namespaces sequences uuid bson.writer.private ;
|
||||||
|
|
||||||
IN: alien.c-types
|
IN: alien.c-types
|
||||||
|
|
||||||
|
@ -38,12 +38,6 @@ SYMBOL: msg-bytes-read
|
||||||
: change-bytes-read ( integer -- )
|
: change-bytes-read ( integer -- )
|
||||||
bytes-read> [ 0 ] unless* + >bytes-read ; inline
|
bytes-read> [ 0 ] unless* + >bytes-read ; inline
|
||||||
|
|
||||||
: write-byte ( byte -- ) 1 >le write ; inline
|
|
||||||
: write-int32 ( int -- ) 4 >le write ; inline
|
|
||||||
: write-double ( real -- ) double>bits 8 >le write ; inline
|
|
||||||
: write-cstring ( string -- ) output-stream get utf8 encoder-write 0 write-byte ; inline
|
|
||||||
: write-longlong ( object -- ) 8 >le write ; inline
|
|
||||||
|
|
||||||
: read-int32 ( -- int32 ) 4 [ read le> ] [ change-bytes-read ] bi ; inline
|
: read-int32 ( -- int32 ) 4 [ read le> ] [ change-bytes-read ] bi ; inline
|
||||||
: read-longlong ( -- longlong ) 8 [ read le> ] [ change-bytes-read ] bi ; inline
|
: read-longlong ( -- longlong ) 8 [ read le> ] [ change-bytes-read ] bi ; inline
|
||||||
: read-byte-raw ( -- byte-raw ) 1 [ read le> ] [ change-bytes-read ] bi ; inline
|
: read-byte-raw ( -- byte-raw ) 1 [ read le> ] [ change-bytes-read ] bi ; inline
|
||||||
|
@ -156,7 +150,7 @@ USE: tools.walker
|
||||||
|
|
||||||
: (write-message) ( message quot -- )
|
: (write-message) ( message quot -- )
|
||||||
'[ [ [ _ write-header ] dip _ call ] with-length-prefix ] with-buffer
|
'[ [ [ _ write-header ] dip _ call ] with-length-prefix ] with-buffer
|
||||||
! [ dump-to-file ] keep
|
[ dump-to-file ] keep
|
||||||
write flush ; inline
|
write flush ; inline
|
||||||
|
|
||||||
: build-query-object ( query -- selector )
|
: build-query-object ( query -- selector )
|
||||||
|
|
Loading…
Reference in New Issue