-
Notifications
You must be signed in to change notification settings - Fork 2
05 Configuration
Robert Friberg edited this page May 29, 2014
·
4 revisions
In this exercise you will modify an existing model to use ProtoBuf formatting for the journal and snapshots. The current configuration uses BinaryFormatter serialization. For each operation, take a note of the duration printed to the console.
The console app relies on command line arguments. If you're uncomfortable with the command line, you can enter arguments under Project/Properties/Debug or just hardcode args into the console app. Better yet why not just use scriptcs?
- Open and examine the solution
Ex01\FreeDb.sln - Build the model by running the console application using the compressed bz2 file found under Resources as input.
- Quit the application and run again, this time loading the from journal previously built.
- Take a snapshot
- Quit and run again, this time loading from snapshot
- Take a note of the size of the journal and snapshot
- Add a nuget reference to origodb.protobuf in the FreeDb.App project
- Create a method that builds an EngineConfiguration instance configured for protobuf snapshotting using code only configuration. It could look like this:
static EngineConfiguration CreateProtobufConfig() { var config = new EngineConfiguration(); var typeModel = TypeModel.Create(); typeModel.Add(typeof (FreeDbModel), false) .Add(1, "_tracks"); typeModel.Add(typeof (Track), false) .Add(1, "Artist") .Add(2, "Title") .Add(3, "Album") .Add(4, "Genre"); ProtoBufFormatter.ConfigureSnapshots<FreeDbModel>(config, typeModel); return config; }
- Modify the Build and Load methods to use the protobuf configuration
- Repeat the runs and compare sizes / timings