|
| 1 | + |
| 2 | +package com.mongodb.framework; |
| 3 | + |
| 4 | +import java.util.*; |
| 5 | +import java.net.*; |
| 6 | + |
| 7 | +import com.mongodb.*; |
| 8 | +import com.mongodb.util.*; |
| 9 | + |
| 10 | +public class Stress1 { |
| 11 | + |
| 12 | + public static void doStuff( DBCollection c, int count ) { |
| 13 | + DBObject obj = new BasicDBObject(); |
| 14 | + obj.put( "id", count ); |
| 15 | + DBObject x = c.findOne( obj ); |
| 16 | + x.put( "subarray", "foo" + count ); |
| 17 | + c.save( x ); |
| 18 | + } |
| 19 | + |
| 20 | + public static void main(String[] args) |
| 21 | + throws UnknownHostException { |
| 22 | + |
| 23 | + Mongo m = new Mongo( new DBAddress( "127.0.0.1:27017/driver_test_framework" ) ); |
| 24 | + DBCollection c = m.getCollection( "stress1" ); |
| 25 | + |
| 26 | + String blah = "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" + |
| 27 | + "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" + |
| 28 | + "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" + |
| 29 | + "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" + |
| 30 | + "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas" + |
| 31 | + "lksjhasoh1298alshasoidiohaskjasiouashoasasiugoas"; |
| 32 | + |
| 33 | + for( int i=0; i<50000; i++ ) { |
| 34 | + DBObject foo = new BasicDBObject(); |
| 35 | + foo.put( "name", "asdf"+i ); |
| 36 | + foo.put( "date", new Date() ); |
| 37 | + foo.put( "id", i ); |
| 38 | + foo.put( "blah", blah ); |
| 39 | + c.save( foo ); |
| 40 | + } |
| 41 | + |
| 42 | + for( int count=0; count<10000; count++ ) { |
| 43 | + doStuff( c, count ); |
| 44 | + } |
| 45 | + |
| 46 | + DBObject idx = new BasicDBObject(); |
| 47 | + idx.put( "date", 1 ); |
| 48 | + c.ensureIndex( idx ); |
| 49 | + } |
| 50 | +} |
0 commit comments