[Mono-list] Very fast growing of serialization time for big array

Yury Serdyuk Yury at serdyuk.botik.ru
Sat Feb 27 07:21:28 EST 2010


Hi !

I have tried to serialize a big array of floats ( more than 270 millions 
elements )
and observed a very fast growing of serialization time.

In fact this growing is observed from the size = 270 204 922.
Below is a corresponding protocol:

> bash-3.2$ mono BigSerializationTest.exe 270204920
> Serialization time = 1.271595 secs.
> bash-3.2$ mono BigSerializationTest.exe 270204921
> Serialization time = 1.236961 secs.
> bash-3.2$ mono BigSerializationTest.exe 270204922
> Serialization time = 2.433673 secs.
> bash-3.2$ mono BigSerializationTest.exe 270204923
> Serialization time = 2.425419 secs.
> bash-3.2$ mono BigSerializationTest.exe 270204924
> Serialization time = 2.44311 secs.
> bash-3.2$ mono BigSerializationTest.exe 270204950
> Serialization time = 2.846783 secs.
> bash-3.2$ mono BigSerializationTest.exe 270204980
> Serialization time = 2.84799 secs.
> bash-3.2$ mono BigSerializationTest.exe 270205000
> Serialization time = 2.845296 secs.
> bash-3.2$ mono BigSerializationTest.exe 270206000
> Serialization time = 3.428312 secs.
> bash-3.2$ mono BigSerializationTest.exe 270210000
> Serialization time = 4.644107 secs.
> bash-3.2$ mono BigSerializationTest.exe 270250000
> Serialization time = 21.2402 secs.
> bash-3.2$ mono BigSerializationTest.exe 270300000
> Serialization time = 40.710206 secs.
> bash-3.2$ mono BigSerializationTest.exe 270500000
> Serialization time = 119.514284 secs.
> bash-3.2$ mono BigSerializationTest.exe 271000000
> Serialization time = 316.298852 secs.

The code for testing was:

> using System;
> using System.IO;
> using System.Runtime.Serialization;
> using System.Runtime.Serialization.Formatters.Binary;
>
> public class BigSerializationTest {
>
>  public static void Main ( String[] args ) {
>
>   int size = Convert.ToInt32 ( args [ 0 ] );
>
>   BinaryFormatter bf = new BinaryFormatter();
>   MemoryStream    ms = new MemoryStream();
>
>   float[] array = new float [ size ];
>
>   for ( int i = 0; i < array.Length; i++)
>    array [ i ] = 1.0f;
>
>   DateTime dt1 = DateTime.Now;
>   bf.Serialize ( ms, array );
>   DateTime dt2 = DateTime.Now;
>
>   Console.WriteLine ( "Serialization time = " + (dt2-dt1).TotalSeconds 
> + " secs." );
>
>  }
>
>
> }

Do any have some thoughts about reasons of this problem and
how to resolve it ?

Thanks.

Yury


More information about the Mono-list mailing list