[Vala] Why is Vala 10 times slower than C ?
- From: Serge Hulne <serge hulne gmail com>
- To: vala-list gnome org
- Subject: [Vala] Why is Vala 10 times slower than C ?
- Date: Mon, 6 Jun 2011 14:12:37 +0200
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;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]