Performance issues with OPC createRelationship methods

Odpovědět Performance issues with OPC createRelationship methods

  • lunes, 28 de febrero de 2011 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";
      
                File.Delete(packageFile);

                Stopwatch s = new Stopwatch();

                s.Start();
                // 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();
                    formatter.Serialize(stream, data);
                    stream.Close();

                    // Create a package-level relationship to the data
                   package.CreateRelationship(part.Uri, TargetMode.Internal, "data");
                }
                package.Close();
                s.Stop();
                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?

     

     

Todas las respuestas