Does pooling work ?
Hi everybody.
I've been doing some load testing with .NEt connecter 1.0.2 gamma, and i've kinda come to the conclusion that pooling ain't really working.
I've included a small test program so you can test it out. On my machine, the first version runs 10 times as fast as the one that should pool...
using System;
using MySql.Data.MySqlClient;
namespace TestApp {
delegate void testMethod(int iterations);
class TestPooling {
[STAThread]
static void Main(string[] args) {
test( new testMethod(best),"Very best (use a single connection)" );
test( new testMethod(realistict),"Pooling" );
Console.Read();
}
private static void test(testMethod test, string name) {
Console.WriteLine("Testing " + name);
DateTime now = DateTime.Now;
for(int i=0;i!=10;i++){
test(10);
Console.Write(".");
}
Console.WriteLine( "\nTotalTime: " + (DateTime.Now-now).Ticks + "\n");
}
private static void realistict(int iterations) {
for(int i=0;i!=iterations;i++){
MySqlConnection connection = new MySqlConnection( "server=oliver; user id=viral; password=tjuhejher; database=viral; pooling=true" );
connection.Open();
MySqlCommand command = new MySqlCommand("show tables");
command.Connection = connection;
MySqlDataReader reader = command.ExecuteReader();
while(reader.Read()){}
reader.Close();
connection.Close();
}
}
private static void best(int iterations) {
MySqlConnection connection = new MySqlConnection( "server=oliver; user id=viral; password=tjuhejher; database=viral; pooling=true" );
connection.Open();
for(int i=0;i!=iterations;i++){
MySqlCommand command = new MySqlCommand("show tables");
command.Connection = connection;
MySqlDataReader reader = command.ExecuteReader();
while(reader.Read()){}
reader.Close();
command.Dispose();
}
connection.Close();
}
}
}
Subject
Written By
Posted
Does pooling work ?
November 25, 2004 03:06PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.