Skip to content

Instantly share code, notes, and snippets.

@freeeve
Created February 2, 2012 22:26
Show Gist options
  • Save freeeve/1726181 to your computer and use it in GitHub Desktop.
Save freeeve/1726181 to your computer and use it in GitHub Desktop.
generate random data for some compound index ordering comparisons
function getRandomTime() {
return new Date(new Date() - Math.floor(Math.random()*1000000));
}
function initialInsert() {
// insert 1 million records
for(var i = 0; i < 1000000; i++) {
db.test.save({
date_added:getRandomTime(),
optical_lumo:Math.random()*30-10, // let's make the range 1/3 of the result
basis: "6-31g(d)", // this isn't going to help us unless we know the cardinality of the field to model it better
lumo:Math.random()*30-10, // let's make the range 1/3 of the result
homo:Math.random()*30-10, // let's make the range 1/3 of the result
sum:Math.random()*200, // *** let's make the range 1/20 of the result
gap:Math.random()*20, // let's make the range 1/4 of the result
solar_product:Math.random()*100000 // about 1/3 of the result
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment