Httpcontext
// Write
Stopwatch Sw = New Stopwatch ();
Sw. Start ();
For ( Int I = 1 ; I <= 100000 ; I ++)
{
VaR M = New MAN ()
{
Age = 1 ,
Height = 2
};
Httpcontext. Current. cache [I. tostring ()] = m;
}
Sw. Stop ();
Debug. writeline (SW. elapsedmilliseconds );
//Read
Sw. Start ();
For(IntJ =1; J <=100000; J ++)
{
VaRM = httpcontext. Current. cache [J. tostring ()];
}
Sw. Stop ();
Debug. writeline (SW. elapsedmilliseconds );
The result is:
181
249
Appfabric
VaR DCF = New Datacachefactory ();
VaR Cache = DCF. getcache ( " Default " );
//Write
Stopwatch Sw =NewStopwatch ();
Sw. Start ();
For ( Int I = 1 ; I <= 100000 ; I ++)
{
VaR M = New MAN ()
{
Age = 1 ,
Height = 2
};
Cache. Put (I. tostring (), M );
}
Sw. Stop ();
Debug. writeline (SW. elapsedmilliseconds );
//Read
Sw. Start ();
For(IntJ =1; J <=100000; J ++)
{
VaRM = cache. Get (J. tostring ());
}
Sw. Stop ();
Debug. writeline (SW. elapsedmilliseconds );
The result is
133979 (write time)
263803 (total read + write time)
Supplement the test result of application:
103184
//Write
Stopwatch Sw = New Stopwatch ();
Sw. Start ();
For ( Int I = 1 ; I <= 100000 ; I ++)
{
VaR M = New MAN ()
{
Age = 1 ,
Height = 2
};
Application [I. tostring ()] = m;
}
Sw. Stop ();
Debug. writeline (SW. elapsedmilliseconds );
//Read
Sw. Start ();
For(IntJ =1; J <=100000; J ++)
{
VaRM = application [J. tostring ()];
}
Sw. Stop ();
Debug. writeline (SW. elapsedmilliseconds );