Željko Filipin's Blog on Software and Testing

Test like you do not need the money.

Archive for the ‘.NET’ Category

Ruby Mail and benchmark.rb on CRuby, JRuby, IronRuby and RubyInstaller

with 4 comments

Update: Steve suggested I should try the script also with RubyInstaller, and I did it.

This blog post is update of my recent Ruby Mail on CRuby, JRuby and IronRuby post. Mikel and Jimmy have commented on the post saying I did a poor job, and I would agree. I decided to do a better job this time. Please let me know if measurements can be further improved.

So, I have an e-mail file called 1.eml:

Date: Thu, 24 Dec 2009 14:37:34 Central European Standard Time
From: from@test.com
To: to@test.com
Message-ID: <4b336e9e762a0_a1014263a4689d3@2003-ie7.mail>
Subject: This is a test email
Mime-Version: 1.0
Content-Type: text/plain;
	charset="US-ASCII";
Content-Transfer-Encoding: 7bit

Some text for mail body

The First Try

This is the test from the first post. (RubyInstaller was not included in the first post.) It is included here so all code and numbers are at the same page, I guess it is easier to compare that way. Read the file, display subject and total time elapsed (in seconds).

time = Time.now
require "rubygems"
require "mail"
mail = Mail.read("1.eml")
puts mail.subject.to_s
puts Time.now - time

Executed the script three times for each Ruby implementation. RubyInstaller the fastest, CRuby and JRuby were similar in speed, IronRuby was way slower.

Test Run 1 2 3
CRuby 2.594 2.109 2.11
JRuby 3.0 2.016 2.0
IronRuby 9.8125 7.796875 7.6875
RubyInstaller 1.21875 1.203125 1.203125

The Second Try

Since both Mikel and Jimmy said require could take the majority of the time, and I was not really interested in measuring that, I excluded it from the measurement.

require "rubygems"
require "mail"

time = Time.now
mail = Mail.read("1.eml")
puts mail.subject.to_s
puts Time.now - time

Times were way shorter. RubyInstaller the fastest (can not get much faster that 0.0 seconds), CRuby and JRuby in the same order of magnitude, IronRuby order of magnitude slower. JRuby has surprisingly the same numbers every time.

Test Run 1 2 3
CRuby 0.015 0.016 0.0
JRuby 0.047 0.047 0.047
IronRuby 0.5 0.46875 0.484375
RubyInstaller 0.0 0.0 0.0

Benchmark

Mikel and Jimmy have suggested that I should use benchmark.rb, so I took a look. I have slightly modified the script. This time the file was read 1000 times.

require "rubygems"
require "mail"
require "benchmark"

Benchmark.bm do |x|
  x.report { 1000.times do; puts Mail.read("1.eml").subject.to_s; end }
end

This measurement said JRuby was the fastest, followed closely by RubyInstaller and CRuby, IronRuby again order of magnitude slower.

Test Run user system total real
CRuby 11.000000 0.657000 11.657000 13.485000
JRuby 6.187000 0.000000 6.187000 6.187000
IronRuby 69.984375 7.140625 77.125000 60.656250
RubyInstaller 7.297000 0.766000 8.063000 9.953125

Environment

Tests were run in VMware Fusion 2.0.6 virtual machine, 512 MB RAM, Microsoft Windows Sever 2003 R2 (Standard Edition, Service pack 2).
Host machine is MacBook Pro, 2.4 GHz Intel Core 2 Duo, Mac OS X 10.6.2, 4 GB RAM.

>ruby -v
ruby 1.8.6 (2007-09-24 patchlevel 111) [i386-mswin32]

>jruby -v
jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3) (Java HotSpot(TM) Client VM 1.6.0_10) [x86-java]

>ir -v
IronRuby 0.9.3.0 on .NET 2.0.0.0

>ruby -v
ruby 1.8.6 (2009-08-04 patchlevel 383) [i386-mingw32]

Mail version 1.3.4 on all platforms.

Written by Željko Filipin

January 5th, 2010 at 7:15 pm

Posted in .NET,Ruby,Software

ASP.NET – Install Everything You Need

without comments

Recently I started to play with ASP.NET. I found asp.net, The Official Microsoft ASP.NET 2.0 Site. The first thing you have to do is to install required software.

In my opinion, they made the installation to complicated for total beginner. There are too many choices. I wish they had something like Instant Rails. I lost some time figuring it out, so I decided to share my experience. Maybe it will help somebody. If you have comments, improvements, or if I did something wrong, please leave a comment.

At asp.net home page there is link GET ASP.NET. It leads to Essential Downloads page. There they say you need Microsoft .NET Framework Version 2.0 (framework) and Visual Web Developer 2005 Express Edition (IDE). Language version was easy to choose (English), but do I need Framework or SDK version of framework? That was also easily answered when I saw

If you are new to web development, select the Framework download.

The truth is that you do not have to download framework. It will automatically be downloaded when you download IDE. I selected English version of IDE.

Download page opens with four easy steps.

The first step was to check if my computer meets the System Requirements. It did. That was easy enough. Also, uninstall any previous versions of SQL Server 2005, IDE and framework. I did not have any installed.

The second step is to download IDE. But, there is just to many options. Six. I just want to download an IDE for language I do not know nothing about, and they make me choose. I just knew that my developer uses ASP.NET and C#. And at that page there are Visual Web Developer and Visual C# IDE-s. Later I found out that I do not need Visual C#. (But after I downloaded and installed it. Do not make the same mistake.)

After download (Visual Web Developer is what you need), execute downloaded file. Of course, you have to be logged in as administrator. At the third screen of installation wizard there is option to also download and install Microsoft MSDN 2005 Express Edition and Microsoft SQL Server 2005 Express Edition x86. You need only SQL Server. At the next screen I noticed that Microsoft .NET Framework 2.0 will also be installed.

The third step is to download updates and additional components. You can install additional components later if you want to, no need to do it now. You do not have to download updates if you perform Microsoft Update after installation. That is what I did. There was two updates for .NET Framework and one for Visual Studio. I just wonder why they just do not offer the newest version of IDE and .NET framework, but instead you have to download an old version and than update it.

The fourth step is registration. You have 30 days, so there is no rush. But beware (from FAQ):

Without a registration key, downloaded Editions will no longer work after 30 days.

So, all you have to do is to download Visual Web Developer, make sure that SQL Server is also downloaded (while installing IDE) and perform Microsoft Update after installation.

Written by Željko Filipin

April 20th, 2007 at 4:16 pm

Posted in .NET

First Steps in ASP.NET

without comments

asp.png

My developer is using ASP.NET. I decided to learn basics of it. After all, you have to know your enemy. As it usually goes, pretty soon I got into trouble. Internet Information Services (IIS 5.1) at my machine (Windows XP Professional, Service Pack 2) was processing server code of asp pages, but not of aspx. Internet Explorer would show HTML portion of aspx page, but server code was ignored. Firefox was showing asp pages, but for aspx pages I was getting “open with” pop-up.

What went wrong? .NET Framework and IIS are installed.

I started looking at Internet Information Services (Start > All Programs > Administrative Tools > Internet Information Services). At ASP.NET tab of Web Sites Properties window (Internet Information Services > local computer > Web Sites > right click > Properties ) I saw that ASP.NET version is not selected, so I selected 2.0.50727 (1.1.4322 was also available).

No luck. I started getting this error page.

Server Application Unavailable

Time to ask my developer for help. He said I should create virtual directory.

  • at C:\Inetpub\wwwroot\ create directory asp
  • Internet Information Services > local computer > Web Sites > Default Web Site > right click > New > Virtual Directory… > enter alias (“asp” sounds good) > browse to directory > make sure “Read” and “Run scripts (such as ASP)” checkboxes are checked
  • Internet Information Services > local computer > Web Sites > Default Web Site > virtual directory alias (“asp”, remember) > right click > Properties > ASP.NET > ASP.NET version > 2.0.50727

Then I got different error message.

Failed to access IIS metabase.

According to Failed to access IIS metabase blog post from R. Aaron Zupancic, the problem was:

You may have installed IIS after installing the .NET framework.

True. I installed .NET framework immediately after I installed Windows, and I installed IIS later when I needed it. Solution? Open command prompt, go to C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 and execute

aspnet_regiis -i

Everything works fine now. Firefox needed some time to start recognizing aspx pages (I was still getting “open with” pop-up), but now it works.

Written by Željko Filipin

March 22nd, 2007 at 2:13 pm

Posted in .NET