Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

New competition: do you accept the challenge?! :-)

 [1/35] from: ale870::gmail::com at: 6-Nov-2007 22:51


Hi, today I was checking Rebol performance vs Java. So, my first test was some calculation tests. Performance were comparable! (I like it!!!). Then I made some strings peformance tests. In this case I got bad results. Infact, it seems Java is REALLY FASTER than Rebol :-( So, my competion proposal is the following: creating a Rebol application faster than the corresponding java one. This is the java program (very easy): ==================================================================== public class Prova1 { public Prova1() { System.out.println("START..."); StringBuffer finale = new StringBuffer(); for(int i=1; i<10001; i++) { StringBuffer str = new StringBuffer(); for(int j=1; j<501; j++) { str.append(String.valueOf(i)).append(",").append( String.valueOf(j)).append("-"); } finale.append(str.substring(1, 5)); } System.out.println("COMPLETED!!!"); System.out.println(finale.toString()); System.out.println(finale.length()); } public static void main(String[] args) { new Prova1(); } } ==================================================================== rebol [] print "START..." s1: now str: make string! 1000 finale: make string! 10000 repeat i 10000 [ clear str repeat j 500 [ append str reduce [i "," j "-"] ] append finale copy/part skip str 1 4 ] print "STOP!" print length? finale print (now/time - s1/time) halt ==================================================================== Can you optimize it in order to make it faster? Just for curiosity. I have a notebook HP nc6320, Dual Core with 2Gb ram. Performance results are: Java application: 5 seconds. Rebol application: 16 seconds And now... the competion begins!!!! As I made in the previous competion, I will publish the results in my site (it will be a good tutorial for the beginners!!!) Site (for Rebol desktop) is: http://sguish.50webs.org/index.r (I'm sorry, some items are in Italian language, since I maintain the site and a blog for italian people). Thank you! -- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [2/35] from: dhsunanda:gma:il at: 6-Nov-2007 15:32


Two very quick changes just to get into the spirit of the competition: 1. pre-allocate all space needed to the strings 2. use insert tail rather than append (append is not native in R2) Runs in about 65% of the time of the original. Still not as close as Java, but it was only a minute's work. Someone is sure to do much better. I suspect both Java and REBOL depend on the string handling libraries of the compiler they are compiled under. That may mean the relative timings will vary according to platform and release. Sunanda Changed code..... print "START..." s1: now str: make string! 5000 finale: make string! 50000 repeat i 10000 [ clear str repeat j 500 [ insert tail str reduce [i "," j "-"] ] insert tail finale copy/part skip str 1 4 ] print "STOP!" print length? finale print (now/time - s1/time)

 [3/35] from: tomc:cs:uoregon at: 6-Nov-2007 14:30


Sunanda wrote:
> Two very quick changes just to get into the spirit of the competition: > 1. pre-allocate all space needed to the strings
<<quoted lines omitted: 21>>
> print length? finale > print (now/time - s1/time)
what Sun said with a little cheating rebol [] print "START..." s1: now str: make string! 4800 finale: make string! 48000 repeat i 10000 [ repeat j 500[ insert tail str i ;insert tail str "," insert tail str j ;insert tail str "-" ] insert tail finale copy/part str 2 insert back tail finale "," insert tail finale "-" clear str ] print "STOP!" print length? finale print (now/time - s1/time) halt -- ... nice weather eh tomc-cs.uoregon.edu

 [4/35] from: hallvard:ystad:babelserver at: 6-Nov-2007 23:32


Sorry not to advance the rebol code in any manner, but here are some results with your initial code from two other machines: Windows XP SP2, Pentium D 3GhZ, 3G RAM: Rebol code: 16 seconds Java code: 3,5 seconds Mac PPC, OS 10.4, old machine: Rebol: 01:27 (!) Java: 17,8 seconds Good luck to contestants! HY Dixit Alessandro Manotti (22.51 06.11.2007):

 [5/35] from: ale870:gm:ail at: 7-Nov-2007 0:10


Ok guys, we started very well First of all: thank you Sunanda for your tricks! My Rebol application gained many precious seconds (from 16 secs to 11 secs). Then I tried to split a single "insert tail reduce" in different lines (without reduce), but I didn't gain time, instead I lost some seconds (from 11 secs to 15 secs). Tom, I was very impressed from your code, but it seems the result is not identical (try to print "finale" in every external loop, in the original code and in your code, the result is very similar but not identical). However, your code takes only 8 secs. If you can fix such issue, It seems a very good script! :-) I was impressed even by Hallvard results: it seems Rebol for Mac is fairly not optimized! I think Carl and co. should carefully consider this fact, don't you think? On Nov 6, 2007 11:32 PM, Hallvard Ystad <hallvard.ystad-babelserver.org> wrote:
> Sorry not to advance the rebol code in any manner, but here are some > results
<<quoted lines omitted: 125>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [6/35] from: gregg:pointillistic at: 6-Nov-2007 16:23


Hi Alessandro, AM> So, my competion proposal is the following: creating a Rebol application AM> faster than the corresponding java one. Is the goal just to create the same result, or just to optimize string ops in loops? -- Gregg

 [7/35] from: ale870:gm:ail at: 7-Nov-2007 0:36


Well Gregg, obviously we need to achieve the same result (else the comparison will fail!), but we need to optimize rebol program. Basically we need to maintain the program "logic" (loops, etc...). My target is not showing that java is faster than Rebol, but I'm trying to understand what are the "strong" points and "weak" points of Rebol. For example, until now, it seems Rebol does not manage very well strings (compared to Java). But we need to consider that java, in order to optimize string management, it introduced StringBuffer object, since String object is immutable, and is is very slow for frequent changes. I think Rebol could follow a similar way, using a specific datatype for strings that must be changed frequently. But this is a partial result. I didn't publish my benchmark about calculations, but I was very impressed: I made a similar loop, but I calculated a formula similar to this: result: result + 100 * sine i Rebol perfomance is very similar to java. Then I made a test for strings, since they are a "delicated" point in many languages (even more if we try to manage long strings, with MANY characters, since it involves good memory management, involves internal references, etc...). I think we could even create other specific tests in order to find weak points in Rebol, in order to try to optimize them, either as final script or as internal P-CODE. But we should not forget that Java is not pure P-CODE, since it includes a JIT (just in time compiler). In fact, Java interpreter machine automatically check the bottle neck and convert them in pure, native, machine language. I think Rebol works only in P-CODE and does not contain a real JIT. On Nov 7, 2007 12:23 AM, Gregg Irwin <gregg-pointillistic.com> wrote:
> Hi Alessandro, > AM> So, my competion proposal is the following: creating a Rebol
<<quoted lines omitted: 6>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [8/35] from: ale870:gma:il at: 7-Nov-2007 0:41


Sorry, I forgot another point that we could evaluate: now much memory is used to perform a specific job. This is very important, since Java uses much memory during the jobs. On Nov 7, 2007 12:36 AM, Alessandro Manotti <ale870-gmail.com> wrote:
> Well Gregg, > obviously we need to achieve the same result (else the comparison will
<<quoted lines omitted: 47>>
> http://sguish.wordpress.com > http://laccio.wordpress.com
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [9/35] from: gregg:pointillistic at: 6-Nov-2007 16:48


Hi Alessandro, AM> obviously we need to achieve the same result (else the comparison will AM> fail!), but we need to optimize rebol program. AM> Basically we need to maintain the program "logic" (loops, etc...). If we achieve the same result, why does the program logic have to be the same? If the result is important, then we need to know what the *specific* output format is, and what drives its generation (so we can get creative in how we generate it). If the logic is important, then it's just brute force, testing REBOL's string handling performance, and there are many less options for optimization. -- Gregg

 [10/35] from: ale870::gmail::com at: 7-Nov-2007 1:02


yes, now I understand what you say. My main target is testing how fast Rebol can handle strings. I compared it with java simply because java is fast, but not so fast like a real compiled application (e.g.: C++, C, Pascal, ADA, Oberon, etc...). The result is import only because that one is the only way I have to be sure that two different programming languages are implementing the same algorithms (so I can compare them). I think we need to optimize Rebol code using specific tokens (e.g.: I used append but now I discovered that "insert tail" is faster because it is native... this is an important optimization). Obviously, if can change the algorithm and you reach the same result, maybe you didn't work on Rebol code, but on programming logic. It means we should apply such optimization even in the java code. If you have a better idea or suggestions in order to check it, please don't hesitate to help me to find a better way (I started this "competition" since I'm creating some rebol cgi, and I asked to myself if rebol will be faster or slower than java ). Of course java server is another technology (not cgi), but now I wish to analyze tha language performances based on the same logic and algorithms. I think we could apply a different logic/algorithms only if we find a rebol trick that could be never applied in java since the "concept" could not be immplemented in java self. On Nov 7, 2007 12:48 AM, Gregg Irwin <gregg-pointillistic.com> wrote:
> Hi Alessandro, > AM> obviously we need to achieve the same result (else the comparison will
<<quoted lines omitted: 10>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [11/35] from: moliad:g:mail at: 6-Nov-2007 21:50


Alessandro, there is one thing you must consider about rebol, and that is the fact that rebol strings are mutable. I am not sure about java, but if you take python as an example, although from a high-level strings *look* mutable, they are not, just like C (which is one of the reasons its so easy to integrate C stuff natively in python, they act and think alike, from within). REBOL can actually 'CHANGE a string. So although I have not yet looked at your algorythm yet, I have had many situations where I was able to take advantage of this and multiply speed tremendously. when I got to comparing python and REBOL they where similar except when some stuff was compilable to C modules in python, where REBOL gets creamed, but otherwise I could often make REBOL faster cause it does not have to RE allocate every string operation all the time. I will be looking into your code, and can already think of several approaches to string handling which have worked for me in the past, so depending on your specific test, one might come as being a few times faster than the others. also know that one specific can make REBOL string handling several times faster (or slower, depending how you see it ;-) and that is knowing the final length of the string or if you even know in advance, about what will stop the loop. when the length is variable and you must stream the output based on the actual string comming in, I can tell you that many things in parse, when optimised for speed are (sometimes MUCH) faster than C compiled code. -MAx On 11/6/07, Alessandro Manotti <ale870-gmail.com> wrote:

 [12/35] from: moliad:gma:il at: 6-Nov-2007 22:01


oh, and also, you must know that and this is based on A LOT of empirical testing while profiling some aspects of liquid, that what has the most effect on REBOL's overall speed is the amount of "things" and ram being managaged. the sad part is that its not linear, and its actually quite exponential. with liquid, doing loops which generated 1000 very large objects of a specific test, took 10 MB and about .5 secs, lets say going to 2000, speed was somewhere around 5 seconds reacing 10000, actually took over 15 minutes and somehow RAM was at 200MB! when I tried 20000 rebol crashed after an hour and a half. now if it where linear... the 20000 object test should have taken 10 seconds! I have been pushing the envelope with R2 doing very largs apps, some would allocate over 700MB ram, and yet, when you do things knowingly... rebol always seems to get by. for example, with liquid, I was able to change my design and allocate and link-up one million concurrent nodes of the same type within one minute using only 400MB. even C compiled code can start having issues when reaching the millions, and java, well forget about it. -MAx On 11/6/07, Maxim Olivier-Adlhoch <moliad-gmail.com> wrote:

 [13/35] from: Tom::Conlin::gmail::com at: 6-Nov-2007 21:51


Alessandro Manotti wrote:
> yes, now I understand what you say. > My main target is testing how fast Rebol can handle strings. I compared it
<<quoted lines omitted: 3>>
> that two different programming languages are implementing the same > algorithms (so I can compare them).
but part of rebol is *not* having to implement the same algorithms. rebol [] print "START..." s1: now/time/precise finale: make string! 48000 i: 1 while[i <= 10000][ insert tail finale copy/part next trim/all form reduce[i ",1-" i] 4 i: 1 + i ] print "STOP!" print length? finale print now/time/precise - s1 halt

 [14/35] from: petr:krenzelok:seznam:cz at: 7-Nov-2007 0:06


My machine shows 15 sec in R2. 12 after following optimisations: rebol [] print "START..." s1: now str: make string! 5000 finale: make string! 50000 j: 0 repeat i 10000 [ clear str loop 500 [ j: j + 1 insert tail str reduce [i #"," j #"-"] ] insert tail finale copy/part next str 4 ] print "STOP!" print length? finale print (now/time - s1/time) halt Just chatted with Carl on r3 world and some of his suggestions: - The line: repeat j 500 [] is very expensive inside a repeat 10000. - Because, repeat must deep copy and rebind its body block 10000 times. - You may want to try a LOOP 500, with just a normal ++ j in there instead. - Also, [i #"," j #"-"] is faster -- but may not be that much faster. - skip str 1 --> next str - Otherwise, seems to look good. Cheers, -pekr-

 [15/35] from: ale870::gmail at: 7-Nov-2007 9:47


Hello, I'm sorry for this delay answering, but I went to sleep (in Italy, it was 01:00 PM). Here I am. Maxim, I partially understood what you say. In fact, talking about C, the strings in C do not exist. Strings are managed using arrays or memory allocation. Memory allocation size can be changed, so using memory allocation to create strings are mutable (resizing memory with "realloc()" ). About exponential memory allocation, it seems funny, and I cannot find a possible reason! Regarding performance, I think it could depend from memory manager or garbage collector algorithms (but I'm not sure!). Tom, your code is FAASSTT but you changed the algorithm. Now I can do a second phase process. I will create the same algorithm concept in Java, and we'll see what happen :-) This is another point-of-view: istead implementing code in java and "copy" it in Rebol, I will get original code in Rebol (so it should be optimized for it) and I'll try to convert it in Java. I will send you the results soon ;-) On Nov 7, 2007 6:51 AM, Tom <Tom.Conlin-gmail.com> wrote:
> Alessandro Manotti wrote: > > yes, now I understand what you say.
<<quoted lines omitted: 82>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [16/35] from: ale870::gmail::com at: 7-Nov-2007 10:04


Hello Petr, your job is really what I was talking about. You maintained the main algorithm, but you optimized it with several tricks. Thank you to Carl for your suggestion. I think such tricks are very important, to better know Rebol structure and internal functioning. On Nov 7, 2007 9:47 AM, Alessandro Manotti <ale870-gmail.com> wrote:
> Hello, I'm sorry for this delay answering, but I went to sleep (in Italy, > it was 01:00 PM).
<<quoted lines omitted: 126>>
> http://sguish.wordpress.com > http://laccio.wordpress.com
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [17/35] from: moliad::gmail at: 7-Nov-2007 10:44


another optimisation instead of : insert tail series value do series: insert series value -MAx On 11/7/07, Alessandro Manotti <ale870-gmail.com> wrote:

 [18/35] from: ale870:gm:ail at: 7-Nov-2007 17:23


I'm sorry, but it seems it doesn't work. Look at my test:
>> series: "Hello Rebol"
== "Hello Rebol"
>> series: insert series "!!!"
== "Hello Rebol"
>> print series
Hello Rebol
>>
series is not updated. What's wrong? On Nov 7, 2007 4:44 PM, Maxim Olivier-Adlhoch <moliad-gmail.com> wrote:
> another optimisation > instead of :
<<quoted lines omitted: 216>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [19/35] from: moliad::gmail::com at: 7-Nov-2007 11:42


insert works AT the start of a string, and returns the string, just at the end of the insert. so your string now actually is "!!!Hello Rebol" when you are looping repeatedly, you will set the point at which to insert, usually the tail of the string, and then the optimisation will work. whenever the loop is done, you just need to reset the series to its head. -MAx On 11/7/07, Alessandro Manotti <ale870-gmail.com> wrote:

 [20/35] from: moliad:gma:il at: 7-Nov-2007 11:45


sorry, my first sentence is misleading. insert works AT the CURRENT position of a series. since a series can be past its start, this incidentaly is like the start of the string, you can effectively be at its tail. -MAx On 11/7/07, Maxim Olivier-Adlhoch <moliad-gmail.com> wrote:

 [21/35] from: sant4:wanadoo at: 7-Nov-2007 18:28


;Hi, to gain speed, remove the 'reduce print "START..." s1: now/time/precise str: make string! 5000 finale: make string! 50000 blk: [i #"," j #"-"] blk2: at blk 3 repeat i 10000 [ clear str change blk i repeat j 500 [ change blk2 j insert tail str blk ] insert tail finale copy/part next str 4 ] print "STOP!" print length? finale print (now/time/precise - s1) ;*** I gain a little more with that print "START..." s1: now/time/precise str2: make block! 4000 finale: make string! 50000 blk: [i #"," j #"-"] blk2: at blk 3 repeat i 10000 [ change blk i clear str2 insert/dup str2 blk 500 str2: skip str2 2 repeat j 500 [ str2: skip change str2 j 3 ] str: to string! str2: head str2 insert tail finale copy/part next str 4 ] print "STOP!" print length? finale print (now/time/precise - s1)

 [22/35] from: kpeters:otaksoft at: 7-Nov-2007 10:46


Hi all ~ Steeve's= implementation clocks in at 5.8 seconds on one of mymachines. I had read= somewhere (maybe on rapideuphoria.com?) that Euphoriais= supposed to have very fast= string processing for an interpreted language (I remember a claim that its= version of awk beat the original awk written in C hands= down). So I asked the= folks over there for a version in compliance with Alessandro's= (on the same= machine it is about 1.5 seconds faster than Steeve's): -- start of program= -- sequence= str sequence= finale atom= st,et puts(1,"START...\n") st == time() finale == "" &#160;&#160;= &#160;&#160;for i=1 to 10000= do &#160;&#160;--Initialize the temporary string &#160;&#160;str == "" &#160;&#160;for j= 1 to 500 do &#160;&#160;= &#160;&#160;-- append the string repesentationsof i and j &#160;&#160;= &#160;&#160;str &sprintf("%d,%d-",{i,j}) &#160;&#160;end= for &#160;&#160;--= Append the firstfour characters of the temp str to the= result &#160;&#160;--= java zero based &#160;&#160;= finale &= str[2..5] end= for et == time() puts(1,= "COMPLETED!!!\n") printf(1,= "%s\n%d\n%f seconds\n", {finale, length(finale), et-st}) -- end of program= -- They seem to have a= few acesup their sleeves with their sequence implementation - it= looks deceivingly simple, but packs a punch. Haven't tried their= To-C translatorwhich should give another big boost. I also don't know= if the code above could be optimized any more without violating= Alessandro's stipulations... Cheers, Kai

 [23/35] from: tom:conlin:gma:il at: 7-Nov-2007 11:37


stealing ideas as quickly as I can halves the time again... rebol [] print "START" s1: now/time/precise finale: make string! 40000 b: [i ",1-" i] repeat i 10000[ change b i all[i < 10 change back tail b i] finale: insert finale copy/part next to string! b 4 ] print now/time/precise - s1 print length? finale: head finale halt Tom wrote:

 [24/35] from: kpeters:otaksoft at: 7-Nov-2007 11:03


Whoa - that was horrible - let's try this again: Steeve's implementation clocks in at 5.8 seconds on one of my machines. I had read somewhere (maybe on rapideuphoria.com?) that Euphoria is supposed to have very fast string processing for an interpreted language (I remember a claim that its version of awk beat the original awk written in C hands down). So I asked the folks over there for a version in compliance with Alessandro's (on the same machine it is about 1.5 seconds faster than Steeve's): -- start of program -- sequence str sequence finale atom st,et puts(1,"START...\n") st = time() finale = "" for i=1 to 10000 do -- Initialize the temporary string str = "" for j = 1 to 500 do -- append the string repesentations of i and j str &= sprintf("%d,%d-", {i,j}) end for -- Append the first four characters of the temp str to the result -- java = zero based finale &= str[2..5] end for et = time() puts(1, "COMPLETED!!!\n") printf(1, "%s\n%d\n%f seconds\n", {finale, length(finale), et-st}) -- end of program -- They seem to have a few aces up their sleeves with their sequence implementation - it looks deceivingly simple, but packs a punch. Haven't tried their To-C translator which should give another big boost. I also don't know if the code above could be optimized any more without violating Alessandro's stipulations... Cheers, Kai

 [25/35] from: gregg::pointillistic::com at: 7-Nov-2007 14:23


AM> This is another point-of-view: istead implementing code in java and "copy" AM> it in Rebol, I will get original code in Rebol (so it should be optimized AM> for it) and I'll try to convert it in Java. I think this brings up an important point. Does a language allow you to think in ways that let you come up with better solutions. Personally, I don't care (99.99% of the time) how languages compare when performing the same operations. I care about the final results. When VB1 came out, people complained that the p-code wasn't as fast as native code would be (under MS DOS BASICs, you could compile to native or p-code, and even use inline assembly). When MS finally added native code compilation support, people complained that the EXEs were bigger. With something like REBOL, it's difficult to compare--pinhole optimization style--since the big picture is what it's all about. -- Gregg

 [26/35] from: ale870::gmail::com at: 7-Nov-2007 23:43


Oh my God! Ok, I will start to study Euphoria... I'm joking!!! :-) Tomc, your solution is very interesting, and you shown how flexible Rebol is! Everybody shows that! I don't know how many programming languages allow to reach the same solution, using the same basic algorithm but using different functions. It's incredible! Today I said to a friend of mine that Rebol has a lot of loops... he said: many loops? How many?! He said "I know FOR....NEXT... and... STOP! " So I replied: Rebol has FOR..NEXT (like), FOREACH, LOOP, REPEAT, FORALL, FORSKIP, etc... He said: " ???? " (that one was the expression of his face!). He was lost! With something like REBOL, it's difficult to compare--pinhole optimization style--since the big picture is what it's all about. I fully agree with you. That's the reason I want to try the reverse process: starting from an optimized rebol application, then try to replicate it in... Euphoria?! C?! Java?- C#?! F# ?! Performance are not important until they are really mandatory! It means, sometimes, languages comparison is important, even when the user says "I need a fast application". In this scenario the language is important. We could even imagine to make a program to get a specific result, then trying to achieve it in different languages, using their own pro and cons. On Nov 7, 2007 10:23 PM, Gregg Irwin <gregg-pointillistic.com> wrote:
> AM> This is another point-of-view: istead implementing code in java and > "copy"
<<quoted lines omitted: 16>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [27/35] from: moliad:gmai:l at: 7-Nov-2007 17:54


in this case, if you want to make rebol shine, you simply create a system which relies on Parse. I did a client which replied faster than the server was able to handle. The server is C I am using a single 4000 line parse rule, which has error reporting at failure points and almost every single item in the stream comming in is either optional or variable length. my xml engine is twice as fast as Firefox and takes up 10 times less ram! and its a two parse process on top of it! If I merged the second tier rules within the first (although brain damaging to attempt ;-) The speed might increase a lot again. -MAx On 11/7/07, Alessandro Manotti <ale870-gmail.com> wrote:

 [28/35] from: moliad:g:mail at: 7-Nov-2007 17:57


there is a word missing in my post! The server is C I am using... should read: "The server is C my Client uses..." also, the two paragraphs are two separate engines. The huge parse rule generates an xml data stream out of an EDI input stream. -MAx On 11/7/07, Maxim Olivier-Adlhoch <moliad-gmail.com> wrote:

 [29/35] from: moliad:g:mail at: 7-Nov-2007 18:24


the other point to add when comparing REBOL is that REBOL's main feature is its syntax (or lack of, in fact). it takes about an 15 minutes to learn how to express ANY kind of thing in REBOL. from pointers, to values, to complex types like tuples and dates. Even objects notation, because of the colon use is so human readable natural it makes you wonder why others never used that exact notation. When I make apps and send prefs files... people are able to edit them with absolutely no training. when I explain how that is the native code format they are sometimes pretty surprised. I mean, even my mom could change the color value of some object member without even knowing is program source code. This is along of what Gregg is talking about. many things do not need to be done in REBOL in the first place. The use of dialects is such a powerfull high level construct, it allows us to run circles around many designs (even in speed) cause we don't have to build an import-export model, and make a file format structure and what have not. instead of filling up structures which define 1500 things, have 150 functions using templates, and type checking ... we can define a language which expresses the problem directly and use a minimal amount of RAM, context and processor, to address it. one single word can represent 100 different things based on the dialect's state at that point. so we don't have to invent 100 different structures for all of those possibilities. and then, just at end of all the dialect's decision making, you call ONE function, which applies WHAT and HOW those 5-10 little words express. if you put in that parse is SCREAMING fast and I dare compare it to many C compiled apps. those 10 little words become almost insignificant in terms of time spent. The issue is that parse is not easily compared for such low level tests as you present cause it a very high-level control system (you should add it to your loop functions list, btw ;-) which prevents a lot of processing from occuring. so unless you present a set of higher-level specs with rules and expected output, its hard to propose solutions using it. -MAx

 [30/35] from: sant4:wanadoo at: 8-Nov-2007 2:30


;A tricky really really fast solution: ;just to say that if we would know the finality of the algorhitm, we would probably use a tricky and really fast solution. print "START..." s1: now/time/precise blk: [i #"," j #"-"] str: make block! 4000 insert/dup str blk 500 str: skip str 2 repeat j 500 [ str: skip change str j 3 ] str: head str finale: make string! 50000 i: 0 loop 10000 [ i: i + 1 str2: to string! reduce cp/part str 5 ; the trick is here, if you cp/part the block before to reduce it, it's really fast. finale: insert finale copy/part next str2 4 ] print "STOP!" print length? head finale print (now/time/precise - s1)

 [31/35] from: moliad::gmail at: 7-Nov-2007 21:14


and here I tought it was because you are just looping 10500 times instead of 5000000. ;-) -MAx On 11/7/07, Steeve ANTOINE <sant4-wanadoo.fr> wrote:

 [32/35] from: moliad:gm:ail at: 7-Nov-2007 21:19


is anyone realising that every one is being smart, but just a few of you guys are right? hehe alessandro wanted to get the SAME algorythm... I'm sure if we did the same kind of optimisations by changing the algorythm, in any language it would also scale in speed :-) as allesandro said, only if we have the same algorythm, do the test mean anything. or only if rebol had such a different paradigm that expressing the algorythm was a one liner. such as when we read a web site extract tags and save to a file (a one liner!) which takes a full page of code in most languages. I want to do a parse version of the whole algorythm (like I did with another challenge recently, where my submission shrank the code size by more than half), I just haven't had time. I do not expect it to be any faster, but seeing that whole algorythm within a few lines would be cool to see. -MAx

 [33/35] from: ale870::gmail::com at: 8-Nov-2007 8:32


Hello Maxim, I think you really focused the situation. A fully agree with you. Rebol syntax is so particular that a configuration file could be even a Rebol program! I agree with you: even my mother could make something useful with Rebol! In fact, in my "challenge", I didn't want to compare programming languages (there are even too many internet sites that do this). I started this adventure only because some times ago, I was implementing a J2EE application, then I asked to myself: can I do the same application in Rebol? More: since this software will have to satisfy about 4000 users, can I use the same server (aka: have I enough "power" in my hands?) that I use to execute J2EE application server + my application, to run the same app -CGI (+ Apache) made in Rebol ? So I decided to make some small, specific applications, not to verify how much code I need to write in Java or Rebol, not to verify if the maintenance could be smarter for Java apps or Rebol apps, but simply to verify, under a big stress, if the Rebol code could go as fast as Java code. Steeve, I will check (and learn :-) ) your version today. I'm very happy about this challenge, since I learned MANY things, many tricks! On Nov 8, 2007 3:19 AM, Maxim Olivier-Adlhoch <moliad-gmail.com> wrote:
> is anyone realising that every one is being smart, but just a few of you > guys are right?
<<quoted lines omitted: 16>>
> To unsubscribe from the list, just send an email to > lists at rebol.com with unsubscribe as the subject.
-- //Alessandro http://sguish.wordpress.com http://laccio.wordpress.com

 [34/35] from: sant4::wanadoo::fr at: 8-Nov-2007 18:44


;Using Rebcode ;At first i just tried to translate as-is: print "START..." s1: now/time/precise str: make string! 5000 finale: make string! 50000 blk: [i #"," j #"-"] do rebcode [][ repeat i 10000 [ head str clear str head str poke blk 1 i repeat j 500 [ poke blk 3 j apply tmp to [string! blk] insert str tmp -1 tail str ] head str next str insert finale str 4 tail finale ] head finale ] print "STOP!" print length? finale print (now/time/precise - s1) ; it's fast but no so much because the use of the command 'apply (to convert integers into strings) ; So i tried to convert integers myself using Table of strings and a (not so) tricky algorytm to concate big numbers. print "START..." s1: now/time/precise str: make string! 5000 finale: make string! 50000 digit: 0 digits: make block! 500 insert digits "0" repeat n 500 [insert tail digits form n] n: 0 do rebcode [][ repeat i 10000 [ head str clear str head str copy stri "," -1 set.i n i until [ ;concat digits to form a big number set.i digit n rem.i digit 10 div.i n 10 pickz char digits digit insert stri char -1 eq.i n 0 ] repeat j 500 [ insert str #"-" -1 pickz char digits j insert str char -1 insert str stri -1 tail str ] head str next str insert finale str 4 tail finale ] head finale ] print "STOP!" print length? finale print (now/time/precise - s1) ;so it's fast but is not 'Rebolish' anymore

 [35/35] from: sant4::wanadoo::fr at: 8-Nov-2007 22:47


; Seems that first send failed. ; First attempt using Rebcode print "START..." s1: now/time/precise str: make string! 5000 finale: make string! 50000 blk: [i #"," j #"-"] do rebcode [][ repeat i 10000 [ head str clear str head str poke blk 1 i repeat j 500 [ poke blk 3 j apply tmp to [string! blk] insert str tmp -1 tail str ] head str next str insert finale str 4 tail finale ] head finale ] print "STOP!" print length? finale print (now/time/precise - s1) ; It' fast but not so much because of the use of the command 'apply to convert integers into strings. ; I tried to compose the convertion by myself, by using a table of constants and a (not so) tricky algorytm ; to compose big numbers with single digits. print "START..." s1: now/time/precise str: make string! 5000 finale: make string! 50000 digit: 0 digits: make block! 500 insert digits "0" repeat n 500 [insert tail digits form n] n: 0 do rebcode [][ repeat i 10000 [ head str clear str head str copy stri "," -1 set.i n i until [ ;concat digits to form a big number set.i digit n rem.i digit 10 div.i n 10 pickz char digits digit insert stri char -1 eq.i n 0 ] repeat j 500 [ insert str #"-" -1 pickz char digits j insert str char -1 insert str stri -1 tail str ] head str next str insert finale str 4 tail finale ] head finale ] print "STOP!" print length? finale print (now/time/precise - s1) ; We gained more speed but the Rebolish way "keep it simple" is gone

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted