Skip to content

Instantly share code, notes, and snippets.

scalaVersion := "2.11.6"
libraryDependencies ++= Seq(
"com.chuusai" %% "shapeless" % "2.1.0"
)
bytes sip farm xx horner fnv
1 55 40 66 66 1000
2 100 74 117 133 1000
4 190 142 222 235 2000
8 363 210 533 470 2666
16 640 347 1000 800 2285
32 1103 307 1684 1280 2000
64 1306 524 2909 2206 1254
128 1600 636 4266 3657 927
256 1729 785 6095 5019 920
[master][/tmp/qoiwjefoiqwejfoiqwjfoiqwejfioqewjioqfew] cat ~/.rspec
--colour
--order random
--profile 5
[master][/tmp/qoiwjefoiqwejfoiqwjfoiqwejfioqewjioqfew] ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
[master][/tmp/qoiwjefoiqwejfoiqwjfoiqwejfioqewjioqfew] ber -fd
Randomized with seed 44318
mod embedded_migrations {
struct EmbeddedMigration {
version: &'static str,
up_sql: &'static str,
};
impl Migration for EmbeddedMigration {
fn version(&self) -> &str {
self.version
}
match cache.entry(sql) {
Occupied(entry) => Ok(entry.get().clone()),
Vacant(entry) => {
let statement = try!(Statement::prepare(&self.raw_connection, entry.key()));
Ok(entry.insert(CachedStatement::new(statement)).clone())
}
}
match cache.entry(sql) {
Occupied(entry) => Ok(entry.get().clone()),
Vacant(entry) => {
let statement = try!(Statement::prepare(&self.raw_connection, entry.key()));
Ok(entry.insert(CachedStatement::new(statement)).clone())
}
}

Benchmarks comparing v0.6.0 with master

PostgreSQL

                                                          v0.6.0 ns/iter  master ns/iter    diff ns/iter   diff %
bench_selecting_0_rows_with_medium_complex_query          223,674         119,463               -104,211  -46.59%
bench_selecting_0_rows_with_trivial_query                 77,281          51,273                 -26,008  -33.65%
bench_selecting_10k_rows_with_medium_complex_query        57,555,386      55,233,745          -2,321,641   -4.03%
bench_selecting_10k_rows_with_medium_complex_query_boxed  58,937,340      54,434,717          -4,502,623   -7.64%
diff --git a/diesel/src/lib.rs b/diesel/src/lib.rs
index 28c60a3..18225b2 100644
--- a/diesel/src/lib.rs
+++ b/diesel/src/lib.rs
@@ -3,6 +3,7 @@
//! found in the README.
#![deny(warnings)]
#![cfg_attr(feature = "unstable", feature(specialization))]
+#![cfg_attr(all(test, feature = "unstable"), feature(test))]
cache.entry(sql).or_insert_with_result(|sql| {
Statement::prepare(&self.raw_connection, &sql)
.map(CachedStatement::new)
}).clone()
use std::fmt;
use std::marker::PhantomData;
fn main() {
// Upper stages
let ablestar = SimpleStage { dry_mass: 667.0, engine: AJ10_104D, };
let baby_sergeant_1 = SimpleStage { dry_mass: BABY_SERGEANT.mass, engine: BABY_SERGEANT };
let baby_sergeant_3 = MultiEngine { dry_mass: BABY_SERGEANT.mass * 3.0, engine: BABY_SERGEANT, engine_count: 3 };
let baby_sergeant_11 = MultiEngine { dry_mass: BABY_SERGEANT.mass * 11.0, engine: BABY_SERGEANT, engine_count: 11 };