Why do you need to copy the same data 100 times to make 200 bit test data? Instead of this
1. Swipe the counter to a value so that you can generate data sequentially
OR
- Using a random function to generate random data
@Test public void testMongoDBTestDataGenerate() { MongoClient mongoClient = new MongoClient("localhost", 27017); DB db = mongoClient.getDB("development"); DBCollection collection = db.getCollection("ssv"); int counter=0; for (int i = 0; i < 873813; i++) { BasicDBObject document = new BasicDBObject(); document.put("database", "test"); document.put("table", "hosting"); BasicDBObject documentDetail = new BasicDBObject(); documentDetail.put("counter0", counter++); documentDetail.put("counter1", counter++); documentDetail.put("counter2", counter++); documentDetail.put("counter3", counter++); documentDetail.put("counter4", counter++); documentDetail.put("counter5", counter++); documentDetail.put("counter6", counter++); documentDetail.put("counter7", counter++); documentDetail.put("counter8", counter++); documentDetail.put("counter9", counter++); document.put("detail", documentDetail); collection.insert(document); } mongoClient.close(); } }
10 eight double-byte char strings and 10 eight-byte numbers => 240B
240B * 873813 = 200 MB
Chaitanya bapat
source share