Re: [Vala] Why is Vala 10 times slower than C ?



This is not really a fair comparison. Try writing the same code as you wrote in vala in C and then compare.

You are now comparing a probably very highly optimized 'wc' with a naïve implementation in vala.


On Mon Jun  6 14:12:37 2011, 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;
       }
}




_______________________________________________
vala-list mailing list
vala-list gnome org
http://mail.gnome.org/mailman/listinfo/vala-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]