Announcement

Collapse
No announcement yet.

why this code runs faster ???

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • startup
    replied
    Originally posted by Imagine Programming View Post
    Care to share how you solved it?
    ok
    let step back
    Originally posted by startup View Post

    when i concat with " _ " the code runs very fast

    when i concat with "_" the code runs so slow
    [/FONT][/SIZE]
    i was totally wrong here
    the slow was in displaying the message

    i put the message for debugging purpose
    so i detect finally that is no difference between concat with " _ " or concat with "_"
    both are fast
    no need for dialog message that consume time
    simply i remove the dialog message line :yes

    Leave a comment:


  • Imagine Programming
    replied
    Originally posted by startup View Post
    thanks shrek
    thanks all
    problem resolved :yes
    Care to share how you solved it?

    Leave a comment:


  • startup
    replied
    thanks shrek
    thanks all
    problem resolved :yes

    Leave a comment:


  • startup
    replied
    shrek
    i make a try to your code
    but also pure lua did not make any diffrence
    thanks shrek for trying help


    any one know why ??

    concat function too slow when i put 1 char
    then become so fast when adding another char to it ??
    so strange

    any explanation ??

    Leave a comment:


  • Shrek
    replied
    Try it with pure Lua:

    Code:
    my_table [COLOR="#FF0000"]=[/COLOR] [COLOR="#FF0000"]{}[/COLOR]
    
    [COLOR="#0000FF"]for[/COLOR] i [COLOR="#FF0000"]=[/COLOR] [COLOR="#000000"]1[/COLOR][COLOR="#FF0000"],[/COLOR][COLOR="#000000"]300[/COLOR] [COLOR="#0000FF"]do[/COLOR]
     [COLOR="#0000FF"]table.insert[/COLOR](my_table[COLOR="#FF0000"],[/COLOR][COLOR="#0000FF"]math.random[/COLOR]([COLOR="#000000"]111111111[/COLOR][COLOR="#FF0000"],[/COLOR][COLOR="#000000"]999999999[/COLOR]))
    [COLOR="#0000FF"]end[/COLOR]
    
    Dialog[COLOR="#FF0000"].[/COLOR]Message([COLOR="#800080"]"Notice"[/COLOR][COLOR="#FF0000"],[/COLOR][COLOR="#0000FF"]table.concat[/COLOR](my_table[COLOR="#FF0000"],[/COLOR][COLOR="#800080"]"_"[/COLOR]))

    Leave a comment:


  • startup
    started a topic why this code runs faster ???

    why this code runs faster ???

    first code
    PHP Code:
    my_table = {}
    for 
    1,300 do
    num Math.Random(111111111999999999);
    Table.Insert(my_tableinum);
    end
    Concated 
    Table.Concat(my_table"_"1TABLE_ALL);
    Dialog.Message("Notice"ConcatedMB_OKMB_ICONINFORMATIONMB_DEFBUTTON1); 
    run very slow

    second code
    PHP Code:
    my_table = {}
    for 
    1,300 do
    num Math.Random(111111111999999999);
    Table.Insert(my_tableinum);
    end
    Concated 
    Table.Concat(my_table" _ "1TABLE_ALL);
    Dialog.Message("Notice"ConcatedMB_OKMB_ICONINFORMATIONMB_DEFBUTTON1); 
    runs very fast

    the deference is in line 5
    in the table.concat function

    when i concat with " _ " the code runs very fast

    when i concat with "_" the code runs so slow

    i need to Concat with "_"
    can i know why slow ??
    is there a solution ??

Working...
X