Fabio,
I only run the tests in Debug environment using Nunit. I run Linq
tests for learning purposes and I'm trying to fix Jet Driver to use
with Access database.
Below is the function CreateNorthwindDb from the class
LinqReadonlyTestsContext where I just inserted Stopwatch to compare
the time of the function ExecuteScriptFile and CreateTestData that use
Nhibernate alone.
The first time you run using CreateTestData, I´m using Nunit GUI , the
function is very slow because, as I mention the framework has to
transform the huge function CreateNorthwindData to native code. If you
run second time,with Nunit opened, you do not have to wait huge
function CreateNorthwindData be compiled , and you are basically
measuring the time that NHibernate takes to create the database and
now CreateTestData is faster than ExecuteScriptFile. I think the
parametrized queries of Nhibernate can be faster than your script
where SQL Server has to interpret all INSERT queries. The problem with
CreateTestData is not with Nhibernate, but with the size of the
function.
private bool _useScript = false;
[SetUp]
public void CreateNorthwindDb()
{
Configuration configuration = Configure();
string scripFileName = GetScripFileName(configuration,
"LinqReadonlyCreateScript");
if (File.Exists(scripFileName) && _useScript)
{
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
ExecuteScriptFile(configuration, scripFileName);
sw.Stop();
Console.WriteLine("ExecuteScriptFile:{0}(ms)",
sw.ElapsedMilliseconds);
}
else
{
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
// may crash with NUnit2.5+ test runner
new SchemaExport(configuration).Create(false,
true);
ISessionFactory sessionFactory =
configuration.BuildSessionFactory();
CreateTestData(sessionFactory);
sw.Stop();
Console.WriteLine("CreateTestData:{0}
(ms)",sw.ElapsedMilliseconds );
}
}
The northwind database from Linq is not so large, maybe 5000 thousand
records, I do not have much experience with Nhibernate, but visiting
Ayende blog ,
http://ayende.com/Blog/archive/2009/08/22/nhibernate-perf-tricks.aspx
he talks about 1000 or 2000 records per second with Nhibernate alone,
maybe you have some Nhibernate benchmarks , the Linq Northwind
database should be saved in less than five seconds, maybe less if you
have good machine. Load 5000 records from a file is fast too.
My point of view is that ExecuteScriptFile is not necessary, maybe is
slower than optimized CreateTestData function with Nhibernate alone
and brings more maintenance work. Even if you wish to keep
ExecuteScriptFile , I think is a good idea to refactor
CreateNorthwindData for people that are using other databases that
does not have SQL scripts.
On Jun 20, 11:39 pm, Fabio Maulo <[email protected]> wrote:
> in TC the difference is:
> was 06:40
> is 03:40
> in my PC around the same; half time.
>
> Ricardo,
> Do you really think that to read data from file and then write data using NH
> is the better we can do ?
> Are you really using NH to upload such amount of data to a cleaned DB ?
>
> How many times you are running NH tests ? before each commit to our
> repository ?
>
>
>
>
>
>
>
> On Sun, Jun 20, 2010 at 9:05 PM, Ricardo <[email protected]> wrote:
> > The method with CreateNorthwindData is still there with large number
> > of lines. See the file
>
> >http://nhibernate.svn.sourceforge.net/viewvc/nhibernate/trunk/nhibern...
>
> > The problem was solved for SQL Server generating an SQL script.
>
> > I note that the problem should be realated with JIT compiler, the dll
> > has Intermediate Language MSIL and only at runtime these thousands of
> > lines of MSIL are converted to machine language when the method
> > CreateNorthwindData is called and this process is consuming too much
> > resources.
>
> > Maybe it´s better solution to refactor the method CreateNorthwindData
> > making a simple loop to read the data from a file and do not use SQL
> > script that must be created for each database (SQL Server, SQLLite,
> > Oracle, ...).
>
> > On Jun 19, 4:44 am, Richard Brown <[email protected]> wrote:
> > > I think the new version of the LINQ tests does exactly that.
>
> > > Sent from my Android phone.
>
> > > On 19 Jun 2010 08:41, "Ricardo" <[email protected]> wrote:
>
> > > I did not test the new version of Linq tests, but the function
> > > CreateNorthwindData with thousands lines of code seems to make visual
> > > studio crawl and consume great amount of memory just to enter the
> > > function. I spitted the function in many parts and the code run much
> > > faster, 5 times or more. I think you could remove the data from C#
> > > code and transfer to a xml file and read the data from a file.
>
> > > On Jun 18, 1:39 am, Fabio Maulo <[email protected]> wrote:
>
> > > > Hi all.
> > > > I have refactorized the t...
> > > > NUnit featurehttp://www.nunit.org/index.php?p=setupFixture&r=2.5.5
>
> > > > <http://www.nunit.org/index.php?p=setupFixture&r=2.5.5>With NUnit2.5+
> > > > testrunner the old tests...
>
> --
> Fabio Maulo