NOODB: It’s Alive!

It’s working, all the way through.

        public void WriteReadIntegrationTest()
            MovieReview review = new MovieReview
                Author = new Author
                    Name = "Jay"
                Movie = new Movie
                    Director = "Director",
                    Name = "DH4"
                Rating = new Rating
                    Id = 0,
                    Score = 5

            const int Inserts = 1000;

            IClient client = new Client(new Server(TestUtility.DefaultUnityContainer));
            Stopwatch insertWatch = new Stopwatch();
            for (int i = 0; i < Inserts; i++)
                review.Rating.Id = i;
                review.Author.Name = "Jay_" + i;
            Console.WriteLine("Insert: " + insertWatch.ElapsedMilliseconds);

            for (int i = 0; i < 20; i++)
                Stopwatch watch = new Stopwatch();
                Collection<MovieReview> reviews = client.GetObjects<MovieReview>();
                Assert.AreEqual(Inserts, reviews.Count);
                Console.WriteLine("Read #" + i + ": " + watch.ElapsedMilliseconds);

The test inserts 1000 objects, then reads them all back 20 times.

Insert: 6992 milliseconds

Read: Ranged from 10143 milliseconds to 10956 milliseconds.

Not bad for a first attempt. Nothing is tuned or optimized. I’m using Net 4, so the parallel technologies are available. there’s one loop in particular where that would come in handy. There are also new thread safe collections; I’ll have to determine the appropriate one to use.

If you get rid of all of the stopwatches, etc, you’re left with this:

IClient client = new Client(new Server(TestUtility.DefaultUnityContainer));
Collection<MovieReview> reviews = client.GetObjects<MovieReview>();

The client is running against and in-process server. It’s designed so that you can put the server elsewhere… otherwise it wouldn’t be a server. Even though it’s in process, all of the serialization is still being used..

The second line saves the object. There isn’t any configuration or anything; the db has never seen this type of object before; it just saves it.

Line 3 retrieves it.


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: