28 Şubat 2011 Pazartesi 22:18
For your project we are planning to use OPC. Our application stores a lot of raw data, each data elements is stored as a seperate part in the OPC file. The typical size of a part is 32 MB. An OPC file can contain 100 parts, so the file will be quite large (3.2 GB).
To test the performance of the OPC we wrote a simple program, the code for saving the file is listed below:
private void button1_Click(object sender, RoutedEventArgs e)
byte data = new byte[1024 * 1024];
// Path and name of the package file.
string packageFile = @"D:\packaging.zip";
Stopwatch s = new Stopwatch();
// Create and open the package file.
Package package = Package.Open(packageFile);
BinaryFormatter formatter = new BinaryFormatter();
for (int i = 0; i < 100; i++)
// Create part uri
Uri partNameUri = PackUriHelper.CreatePartUri(
new Uri("/image" + i.ToString(), UriKind.Relative));
// Create the part.
PackagePart part = package.CreatePart(
partNameUri, "binary/bin", CompressionOption.NotCompressed);
// write data
Stream stream = part.GetStream();
// Create a package-level relationship to the data
package.CreateRelationship(part.Uri, TargetMode.Internal, "data");
FileInfo f = new FileInfo(packageFile);
double fileLength = f.Length / 1.0e6; // file size in Mb)
Console.WriteLine(s.Elapsed +" data rate: " + fileLength/(s.ElapsedMilliseconds /1000) );
When I perform the test I see that the CreateRelationShipMethod has significant impact on the performance:
With CreateRelationShip method: data rate: 13.110676875 MB/sec
Without CreateRelationShip method: data rate: 26.21953975 MB/sec
I run on Windows XP sp3.
Does anybody know why the createrelationship takes so much time?
Does anybody how to make the createrelationship call performing better?
01 Mart 2011 Salı 17:17
Hi M. van Dijk, performance issues are outside of the scope of the Open Packaging Conventions (OPC) forum. Please try posting your question in a forum such as the .NET Base Class Library forum since the Packaging class resides in the System.IO namespace, or the Visual C# General forum for general performance questions. You might also find the information in the following Blog helpful.
Josh Curry (jcurry) | Escalation Engineer | US-CSS DSC Protocols Team
- Yanıt Olarak İşaretleyen Martijn van Dijk 01 Mart 2011 Salı 23:07