On Mon, Jun 06, 2011 at 02:12:37PM +0200, Serge Hulne wrote:
> I used "wordcount" as a test to compare the processing speed of Vala against
> C:
> 
> 
> I obtained the following result:
> 
> ---
> C:
> ---
> serge:vala serge2$ time wc ../shakespeare.txt
>   495200 2703240 15862370 ../shakespeare.txt
> 
> real    0m0.194s
> user    0m0.176s
> sys    0m0.015s
> 
> ---
> Vala:
> ---
> serge:vala serge2$ time ./hello
> lc = 495201. wc = 3170980
> 
> real    0m2.258s
> user    0m2.223s
> sys    0m0.028s
> 
> 
> -------
> 
> The vala code is as follows:
> 
> class HelloWorld : GLib.Object {
>      public static int main(string[] args) {
> 
>             var f = FileStream.open("../shakespeare.txt", "r");
>             var line = "";
>             var wc = 0;
>             var lc = 0;
> 
>             while (!f.eof()) {
>                 line = f.read_line(); lc++;
>                 if (line == null) break;
>                 //stdout.printf("line = %s\n", line);
>                 var words = line.split(" ");
>                 for (int i=0; i<words.length; i++) {
>                     //stdout.printf("word = %s\n", words[i]);
>                     wc++;
>                 }
>             }
> 
>             stdout.printf("lc = %d. wc = %d\n", lc, wc);
>             return 0;
>       }
> }

1) The GType system is initialized
2) read_line() is not as cheap as a getline()
3) str.split() is not as cheap as strtok()

You're just comparing them the wrong way.

-- 
http://www.debian.org - The Universal Operating System
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to