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

2011-06-06 Thread Christian Siefkes
On 06/06/2011 06:53 PM, Christian Siefkes wrote: > I've just seen that somebody already did the same, but I too tried to > optimize your wordcount implementation a bit and got to the following Vala > program: Meanwhile I fixed the program so that it will actually show the correct output, i.e. the

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

2011-06-06 Thread Christian Siefkes
Hi Serge and all, Serge Hulne wrote: > Actually, what I do not grasp is the following: > > - Vala is allegedly just a thin object-oriented layer on top of C (glib2). > > - One might therefore expect a runtime performance which is closer to > say C or C++, than to the (slower) performance of a h

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

2011-06-06 Thread Fabian Deutsch
The attached code produces the following: $ time wc shaks12.txt ; time ./vwc shaks12.txt 124456 901325 5582655 shaks12.txt real0m0.144s user0m0.139s sys 0m0.004s lc = 124456. wc = 1293934 real0m0.161s user0m0.157s sys 0m0.003s So a not so big difference. It really dep

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

2011-06-06 Thread Qball Cow
On Mon Jun 6 17:02:43 2011, Serge Hulne wrote: Hint: Luca already told you why the vala version is slower... Emmanuel. Luca said: --- read_line() is not as cheap as a getline() str.split() is not as cheap as strtok() --- In other words : text processing in *pure Vala* is a lot slower

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

2011-06-06 Thread Luca Dionisi
On Mon, Jun 6, 2011 at 5:02 PM, Serge Hulne wrote: >> Hint: Luca already told you why the vala version is slower... >> >>        Emmanuel. >> >> > > > Luca said: > --- > read_line() is not as cheap as a getline() > str.split() is not as cheap as strtok() > --- You can try and use strtok and fgets

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

2011-06-06 Thread Serge Hulne
> Hint: Luca already told you why the vala version is slower... > >        Emmanuel. > > Luca said: --- read_line() is not as cheap as a getline() str.split() is not as cheap as strtok() --- In other words : text processing in *pure Vala* is a lot slower than in C (or C++ for that matter) Conse

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

2011-06-06 Thread Emmanuel Pacaud
Le lundi 06 juin 2011 à 16:13 +0200, Emmanuel Pacaud a écrit : > Hi, > > Le lundi 06 juin 2011 à 16:03 +0200, Serge Hulne a écrit : > > - However, it turns out that, surprisingly Vala is not only slower > > than C and C++ but even slower than Python. > > > > This is the part that I do not underst

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

2011-06-06 Thread Alexandre Rosenfeld
On Mon, Jun 6, 2011 at 10:03, Serge Hulne wrote: > Actually, what I do not grasp is the following: > > - Vala is allegedly just a thin object-oriented layer on top of C (glib2). > > - One might therefore expect a runtime performance which is closer to > say C or C++, than to the (slower) perform

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

2011-06-06 Thread Serge Hulne
2011/6/6 Гаврилов Максим : > You can benefit reducing code writing time from months to weeks and > forgetting about memory leaks, pure-procedure programming and other pretty > things you used to do in C. ... at the cost of a huge runtime performance penalty. A similar claim was made by the deve

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

2011-06-06 Thread Гаврилов Максим
You can benefit reducing code writing time from months to weeks and forgetting about memory leaks, pure-procedure programming and other pretty things you used to do in C. 06.06.2011 18:11 пользователь "Serge Hulne" написал: > On Mon, Jun 6, 2011 at 3:57 PM, Alexandre Rosenfeld > wrote: >> Or do a

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

2011-06-06 Thread Emmanuel Pacaud
Hi, Le lundi 06 juin 2011 à 16:03 +0200, Serge Hulne a écrit : > - However, it turns out that, surprisingly Vala is not only slower > than C and C++ but even slower than Python. > > This is the part that I do not understand ! Look at the C code generated by valac. You will probably understand wh

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

2011-06-06 Thread Serge Hulne
On Mon, Jun 6, 2011 at 3:57 PM, Alexandre Rosenfeld wrote: > Or do a Vala program without GLib (using the posix profile for instance) and > it will probably be closer to the C version. Does that not kind of defeat the purpose ? How do I benefit from the object-oriented features then ? In parti

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

2011-06-06 Thread Serge Hulne
Actually, what I do not grasp is the following: - Vala is allegedly just a thin object-oriented layer on top of C (glib2). - One might therefore expect a runtime performance which is closer to say C or C++, than to the (slower) performance of a high-level language (like , e.g.Python). - However

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

2011-06-06 Thread Alexandre Rosenfeld
Or do a Vala program without GLib (using the posix profile for instance) and it will probably be closer to the C version. But again, you are comparing two very different things. Vala provides an object-oriented language on top of the GObject system, which in the end compiles to C code. Of course if

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

2011-06-06 Thread Гаврилов Максим
Why do you call it an equivalent version if there's no sign of Glib, garbage collection, etc. in this code? Just write a Glib-based wc in C, and it will be as fast as in Vala. 06.06.2011 17:07 пользователь "Serge Hulne" написал: > Nope ! > > Here is the equivalent version in C: > > #include > >

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

2011-06-06 Thread Serge Hulne
Nope ! Here is the equivalent version in C: #include #include #include int main(int argc, char** argv) { FILE *fp = NULL; char buff[100], *fileName = NULL; int wcnt = 0; int lcnt = 0; if (argc <2) { fprintf(stderr, "Usage: wc \n"); exit(1)