Speed Benchmark: Nested Loop How Fast?

352 views
Skip to first unread message

Clement

unread,
Apr 16, 2025, 5:47:18 AM4/16/25
to The Ring Programming Language
How fast does it take to execute some code within nested for loop?  Tested with multiple programming languages including Ring, Python, Pypy, Julia, Nim and V.  Each code tested running 5 rounds of execution inside VS Code and 5 rounds compiled run to get the average time. Julia and Nim finished at the top on par 0.16 seconds (Nim is compiled using GCC release debug info and optimized settings).  V finished at 0.35 seconds and Pypy comes close at 0.59 seconds.

Here's the results:

PC specs: 13th Gen Intel Core i5-1335U 1.30Ghz / 8.00GB RAM / SSD / Windows 11 64bit
5 rounds average execution time:

Ring run inside VS Code     = 12.82 seconds
Ring compiled -static .EXE = 28.67 seconds

Python run inside VS Code = 7.74 seconds
Python pyinstaller .EXE       = 12.98 seconds
Pypy (run source code)       = 0.59 seconds   (Fast! Python on steroids)

Julia REPL = 0.16 seconds  (Very Fast!)

Nim .EXE gcc compiled = 0.16 seconds  (Very Fast!)

V .EXE compiled = 0.35 seconds   (Fast!)

///////////////////////////////////////////////////////////////////////////
Ring code:
# Ring : Nested for loop execution test

func main()
   
    puts("Ring Nested Loop Test. . .")
    t1 = clock()
    nestedLoop()
    t2 = (clock() - t1) / 1000
    puts("Execution time  : #{t2} seconds")
   
end

func nestedLoop()
    aList = []
    for x = 1 to 10
        for y = 1 to 1000
            for z = 1 to 10000
                if (z + x + y) / 10 = x
                    add(aList, x)
                ok
            next
        next
        puts(x)
    next
end

Python code:
# Pyton : Nested for loop execution test

import timeit

def nestedLoop():
    aList: int = []
    for x in range(10):
        for y in range(1000):
            for z in range(10000):
                if (z + x + y) / 10 == x:
                    aList.append(x)
        print(x)
    return

if __name__ == "__main__":
    print("Python Nested Loop Test. . .")
    execution_time = timeit.timeit(nestedLoop, number=1)
    print(f"Execution time  :  {execution_time:.2f} seconds")
   

Julia code:
# Julia : Nested for loop execution test

function nestedLoop()
    aList = Array{Int32}(undef,0)
    for x = 1:10
        for y = 1:1000
            for z = 1:10000
                if (z + x + y) / 10 == x
                    push!(aList, x)
                end
            end
        end
        println(x)
    end
    return  
end

function main()
   
    println("Julia Nested Loop Test. . .")
    execution_time = @elapsed nestedLoop()
    println("Execution time  :  $(round(execution_time, digits=2)) seconds")

end

main()

Nim code:
gcc compiler optimized release debug info and optimized for speed
nim c -r -d:release --mm:orc --cc:gcc --verbosity:0 --hints:off --opt:speed"

# Nim : Nested for loop execution test

import times, strformat

proc nestedLoop() =
  var aList: seq[int] = @[]
  for x in 0..<10:
    for y in 0..<1000:
      for z in 0..<10000:
        if (z + x + y).float / 10.0 == x.float:
          aList.add(x)
    echo x
  return

when isMainModule:
  echo "Nim Nested Loop Test. . ."

  let startTime = cpuTime()
  nestedLoop()
  let exec_time = cpuTime() - startTime

  echo fmt"Execution time  :  {exec_time:.2f} seconds"

V Code:
// V Nested for loop execution test

import time

fn nested_loop() {
    mut a_list := []int{}
    for x in 0 .. 10 {
        for y in 0 .. 1000 {
            for z in 0 .. 10000 {
                if (z + x + y) / 10 == x {
                    a_list << x
                }
            }
        }
        println(x)
    }
}

fn main() {
    println('V Nested Loop Test. . .')
   
    sw := time.new_stopwatch()
    nested_loop()
    execution_time := sw.elapsed().seconds()
   
    println('Execution time  :  ${execution_time:.2f} seconds')
}


Ilir Liburn

unread,
Apr 16, 2025, 7:32:12 AM4/16/25
to The Ring Programming Language
Hello Clement,

please use aList + x syntax in Ring because it is much faster (uses instruction instead of function call). Additionally, it seems -static switch is slowing down Ring performance (try without -static switch).

BTW, Ring2C is going to be released somewhere before the summer where you can expect performance close to 0.16 sec (because runtime TCC compiler doesn't optimize code like GCC does).  Ring2C project is going to be open source (MIT licence), but there will be no scripting (just plain C with RING_C_API functionality). Scripting is coming later in Ring2C+ (closed source) which will use arrays engine (ISO C99 arrays inside the Ring code).

Greetings,
Ilir

Mansour Ayouni

unread,
Apr 16, 2025, 7:35:12 AM4/16/25
to Ilir Liburn, The Ring Programming Language
Hello Ilir,

Ring2C project is going to be open source (MIT licence)
This is great news for me, Softanza project and all Ring users who are eager for C performance!

Thank you a lot!
Best,
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ring-lang/0c97927b-b5db-43c9-bb5f-dfbcc5336259n%40googlegroups.com.

Ilir Liburn

unread,
Apr 16, 2025, 7:47:57 AM4/16/25
to The Ring Programming Language
Hello Mansour,

Yes, but you need to write C code which you can do also by writing Ring extension. Key difference is: C code doesn't need to be recompiled for each OS and it is possible to link external libraries without building extension.

You're Welcome.

Greetings,
Ilir

Mansour Ayouni

unread,
Apr 16, 2025, 8:00:52 AM4/16/25
to Ilir Liburn, The Ring Programming Language
Yello Ilir,

Yes I understand that and this is what I need! This is also what the Zig language can offer (running C code directly without building any libraries) and that's why I'm planning to add it to the EXCIS system in Softanza soon.

All the best,
Mansour

Mahmoud Fayed

unread,
Apr 16, 2025, 9:01:25 AM4/16/25
to The Ring Programming Language
Hello Clement, Ilir & Mansour

(1) At first this example test (Expression evaluation performance) 

i.e. testing the execution of this line of code (10M times):  if (z + x + y) / 10 = x

(2) As Ilir said using the + operator to add items to a list is faster, but this example add a few items to the list, so using the + operator or pre-allocating the list with specific size will not change the results too much.

(3) Ring is built using GCC, while Ring2EXE -static will use MSVC ---> This is the reason behind the performance difference between using Ring and using Ring2EXE.

(4) Since this sample is about arithmetic operations performance, Ring2C (By Ilir - Ilir-Liburn/Ring2C: Accelerated Ring VM ) run it 75% faster than Ring 1.22 on my machine (i.e. produce performance similar to Python in this task) - It's about arithmetic operations optimization.

 Greetings,
Mahmoud

Ilir Liburn

unread,
Apr 16, 2025, 9:20:31 AM4/16/25
to The Ring Programming Language
Hello Mahmoud,

>>  Ring2C (By Ilir ) run it 75% faster than Ring 1.22 on my machine (i.e. produce performance similar to Python in this task) - It's about arithmetic operations optimization.

Well, that came as surprise because it is based on 1.21 and it was built only to demonstrate arrays (no TCC here). By looking at the source code (which is now 6 months old) I don't see any difference (vmexpr.c) to 1.22. Is it possible this performance improvement comes from the fact I use GCC to build dynamic library (not only executable), or/and by using 32 bit mode or something changed between 1.21 and 1.22 (worst case scenario)?

Greetings,
Ilir
Message has been deleted

Mahmoud Fayed

unread,
Apr 16, 2025, 9:27:05 AM4/16/25
to The Ring Programming Language
Hello Ilir

It's because LoadAPushV optimization that you did to quickly load variable values
In Ring2C this optimization is generalized, while in official Ring VM it's not used in all cases.

Greetings,
Mahmoud

Ilir Liburn

unread,
Apr 16, 2025, 9:35:19 AM4/16/25
to The Ring Programming Language
Hello Mahmoud,

Yes, you are right, LoadA and PushV are joined in one instruction in most cases. But that should bring up to max. 50% performance increase (if only LoadA and PushV are used), but that's not the case. I think it is related to GCC version I use which I'm going to abandon (sadly, because Windows Security complains about virus - false positive probably).

Greetings,
Ilir


Mahmoud Fayed

unread,
Apr 16, 2025, 10:02:42 AM4/16/25
to The Ring Programming Language
Hello Ilir

>> "But that should bring up to max. 50% performance increase (if only LoadA and PushV are used)"

Merging two instructions save the VM fetch/decode time by 50% because we have one instruction instead of two
But there are other factors that have effect on time/performance like

1- Reducing byte code memory because of merging instructions
2- Merging Load & PushV avoid (Stack Push & Stack Pop of the variable name) where we push the value directly

These factors have an effect on the performance too.

Greetings,
Mahmoud

Ilir Liburn

unread,
Apr 16, 2025, 10:39:02 AM4/16/25
to The Ring Programming Language
Hello Mahmoud,

>>  Merging Load & PushV avoid (Stack Push & Stack Pop of the variable name) where we push the value directly

I think this is not correct because LoadAPushV just joins LoadA (which is pushing variable onto stack) and PushV (which is then popping variable from the stack).
No other changes than calls to ring_vm_findvar and ring_vm_varpushv I made here. Also, VM fetch/decode time is negligible (can't bring significant difference like 50% increase).

But I found I made optimizations in general for loading and pushing variables, plus jump optimizations (but no short jump exists in this version).

Greetings,
Ilir 

Mahmoud Fayed

unread,
Apr 16, 2025, 11:06:25 AM4/16/25
to The Ring Programming Language
Hello Ilir

A better and more accurate way is to enable/disable this optimization and measure the sample performance in both cases.

This could provide an accurate percentage.

Greetings,
Mahmoud

Ilir Liburn

unread,
Apr 16, 2025, 11:14:24 AM4/16/25
to The Ring Programming Language
Hello Mahmoud,

Yes, good idea. But I would start by replacing GCC with the MS compiler (although arrays and typehints will not work correctly then because long double is not supported in MS version).
But this is only relevant to Ring2C+ version because RingC is going to use official Ring code. Anyway, I can try it.

Greetings,
Ilir

Ilir Liburn

unread,
Apr 16, 2025, 12:47:30 PM4/16/25
to The Ring Programming Language
Hello Mahmoud,

first small explanation: because my old laptop died (which was 12 years old with Windows 10 - not reporting virus), I moved HDD to even older laptop with AMD 300 E processor which have only 2 cores. Performance is very slow, but clearly demonstrates difference between the compilers

GCC - 154.62 seconds
MSVC - 353.54 seconds

Otherwise, I can't make nested loop test because Windows 11 is reporting a virus and immediately deletes Ring executable built with GCC. As I suspected, main performance improvement comes from the GCC compiler, but I didn't expect such difference.

Greetings,
Ilir

max

unread,
Apr 16, 2025, 12:59:50 PM4/16/25
to The Ring Programming Language
Hello  Ilir ,
Do you use the compilation optimization flgs?

Ilir Liburn

unread,
Apr 16, 2025, 1:09:47 PM4/16/25
to The Ring Programming Language
Hello Max,

Yes, default optimization flags for the MSVC and custom optimization flags for the GCC (I discussed this with Mahmoud, but we found different results).

BTW, I'm repeating this test for the third time using MSVC, last result is 355.51 seconds.

Greetings,
Ilir

max

unread,
Apr 16, 2025, 1:28:49 PM4/16/25
to The Ring Programming Language
hallo IIir,

Check out this tool that allows you to measure the time of each function

Mahmoud Fayed

unread,
Apr 16, 2025, 1:46:03 PM4/16/25
to The Ring Programming Language
Hello Ilir

Interesting results, Thanks for sharing :D

Greetings,
Mahmoud

Ilir Liburn

unread,
Apr 16, 2025, 1:51:38 PM4/16/25
to The Ring Programming Language
Hello Max,

thanks, but two issues here: minor - it is using GUI which isn't good for old hardware (console would be better) and major - I have to use OPTICK_EVENT() call inside the function I expect to be slow. If I know which function (eventually) is slowing down executable, then I don't need such tool.

Greetings,
Ilir

Ilir Liburn

unread,
Apr 16, 2025, 2:09:24 PM4/16/25
to The Ring Programming Language
Hello Mahmoud,

You're Welcome. Better results I also experienced by using the GCC on i7, but it seems on AMD difference widens. Last result for MSVC build today: 353.79 seconds.

Greetings,
Ilir

Youssef Saeed

unread,
Apr 16, 2025, 3:45:08 PM4/16/25
to The Ring Programming Language
Hello Clement et al.,

Here are the results of tests I performed to benchmark Ring against other languages using your nested loop example.

CPU: AMD Ryzen 9 7950X
OS: Arch Linux

Ring:
Clang:
Execution time  : 12.80 seconds
GCC:
Execution time  : 19.12 seconds
GCC + Optimizations:
Execution time  : 18.37 seconds
Clang + Optimizations:
Execution time  : 11.41 seconds
Zig:
Execution time  : 11.51 seconds
Python
Execution time  :  10.89 seconds

Julia
Execution time  :  0.1 seconds

Nim
Execution time  :  0.11 seconds

VLang
Clang:
Execution time  :  0.18 seconds
GCC:
Execution time  :  0.17 seconds
TCC:
Execution time  :  0.18 seconds
Clang + Optimizations:
Execution time  :  0.04 seconds
GCC + Optimizations:
Execution time  :  0.05 seconds

Best regards,
Youssef

Ilir Liburn

unread,
Apr 16, 2025, 5:14:20 PM4/16/25
to The Ring Programming Language
Hello Youssef,

thank you for making a test. Clang is now supported in Visual Studio. I guess, next step is to try Clang on Windows.

Greetings,
Ilir

Clement

unread,
Apr 16, 2025, 7:45:16 PM4/16/25
to The Ring Programming Language
Surprisingly Zig performed slower here, thought Zig is a strong contender compare to Rust.


Zig:
Execution time  : 11.51 seconds

Thanks to everyone who helped test and making Ring faster and more efficient. I'm looking forward to Ring2c.

Julia continues to impress with its blazing speed in numerical computing, though its just-in-time compiler can introduce runtime delays when pre-compiling certain functions. The experimental juliac static compiler shows promise by generating smaller standalone binaries, but remains in development due to challenges with Julia's dynamic typing and garbage collection implementation.

Meanwhile, Python continues to evolve with performance improvements in version 3.13, including experimental work on GIL removal. The ecosystem offers various optimization approaches through tools like Cython, PyPy, Numba, MyPy, and Taichi.

Mojo has captured attention across the Python, Julia, and Nim communities largely due to its implementation of MLIR (Multi-Level Intermediate Representation), which offers new possibilities for performance optimization.


Regards,
Clement

Youssef Saeed

unread,
Apr 16, 2025, 8:07:13 PM4/16/25
to The Ring Programming Language
Hello Clement,

> Surprisingly Zig performed slower here, though Zig is a strong contender compared to Rust.

> Zig:
> Execution time  : 11.51 seconds

Regarding the Zig result, that benchmark shows the performance of Ring built with Zig, not the performance of Zig itself.

Here is the performance of Zig itself for a nested loop:

Execution time  :  0.07 seconds

Best regards,
Youssef

Clement

unread,
Apr 18, 2025, 10:42:43 PM4/18/25
to The Ring Programming Language
Tested with:

Odin = 0.24 seconds

FreeBasic = 0.10 seconds

Bert Mariani

unread,
Apr 19, 2025, 10:55:35 AM4/19/25
to The Ring Programming Language
Thee are Results without doing the Math  and Put
So it really a test of Just the FOR Loop

Ring Nested Loop Test. . .
Execution time  : 9419 milli-seconds
==============
Ring Nested Loop Test 2 -- For Only. . .
Execution time  : 1512 milli-seconds


System Model HP Laptop 15-dy5xxx
OS Name Microsoft Windows 11 Home
Processor 12th Gen Intel(R) Core(TM) i5-1235U, 1300 Mhz, 10 Core(s), 12 Logical Processor(s)

=================================
MODIFIED  Loop 2

# Ring : Nested for loop execution test

func main()
   
    puts("Ring Nested Loop Test. . .")
    t1 = clock()
    nestedLoop()
    t2 = (clock() - t1)
    puts("Execution time  : #{t2} milli-seconds")

? "=============="
    puts("Ring Nested Loop Test 2 -- For Only. . .")

    t1 = clock()
    nestedLoop2()

    t2 = (clock() - t1)
    puts("Execution time  : #{t2} milli-seconds")  

end

func nestedLoop()
    aList = []
    for x = 1 to 10
        for y = 1 to 1000
            for z = 1 to 10000
                if (z + x + y) / 10 = x
                    add(aList, x)
                ok
            next
        next
        puts(x)
    next
end

func nestedLoop2()
    //aList = []

    for x = 1 to 10
        for y = 1 to 1000
            for z = 1 to 10000
                //if (z + x + y) / 10 = x
                //    add(aList, x)
                //ok

            next
        next
        //puts(x)
    next
end 

Bert Mariani

unread,
Apr 19, 2025, 12:18:31 PM4/19/25
to The Ring Programming Language
Note 
Using INTEGER Numbers ...  C CODE in Visual Studio 
Not sure why iVisual Studio C does not work with  float or double declarations
Ring uses Double for numbers

// C Code. - NO Math or Array.
// Time taken : 48 milli - seconds   Ring   1512 milli-seconds  (31 X faster)
//
// C Code
// Time taken: 190 milli-seconds    Ring   9419 milli-seconds  (49 X faster )

//////////////////////////////////////////////////////////////
// C CODE in Visual Studio C

/#include <iostream> \n ;
#include <ctime>

int main()
{
    int x, y, z, r;
    int arrList[10];

    std::cout << "Ring Nested Loop Test. . \n";
    clock_t start = clock();
     
    for ( x = 0; x < 10; ++x)
    {
        for ( y = 0; y < 1000; ++y)
        {
            for ( z = 0; z < 10000; ++z)
            {
                r = (z + x + y) / 10;
                if ( r = x )
                {
                   arrList[x] = x ;
                }

            }
        }
        std::cout << x  <<  "\n" ;
         
    }

   clock_t end = clock();
   double duration = double(end - start);  //  / CLOCKS_PER_SEC;

   std::cout << "Time taken: " << duration << " milli-seconds" << std::endl;
   return 0;
}

// Ring Nested Loop Test. - NO MATH and NO ARRAY.
// Time taken : 48 milli - seconds
//
// Ring Nested Loop Test
// Time taken: 190 milli-seconds

Clement

unread,
Apr 26, 2025, 2:02:20 AM4/26/25
to The Ring Programming Language
Retested the execution time and added a few more languages. Good to keep this benchmark list and we can test with Ring2C when ready.  Results at a glance:

Zig = 0.07 secs
C (gcc) = 0.09 secs
FreeBasic = 0.10 secs
Nim (gcc) = 0.11 secs
JavaScript (Deno) = 0.11 secs
JavaScript (Bun) = 0.12 secs
JavaScript (Node) = 0.12 secs
Julia = 0.12 secs
Odin = 0.24 secs
V = 0.24 secs
Lua = 3.87 secs
Python (numba.njit) = 0.30 secs
Python (Pypy) = 0.42 secs
Python (exe) = 12.98 secs
Python = 7.74 secs
Ring = 12.82 secs
Ring (exe) = 28.67 secs

Clement

unread,
Apr 28, 2025, 7:58:09 PM4/28/25
to The Ring Programming Language
Added Go into the speed benchmark test, Go normal function and with go routines:

Go = 0.15 secs
Go routines = 0.06 secs
Zig = 0.07 secs
C (gcc) = 0.09 secs
FreeBasic = 0.10 secs
Nim (gcc) = 0.11 secs
JavaScript (Deno) = 0.11 secs
JavaScript (Bun) = 0.12 secs
JavaScript (Node) = 0.12 secs
Julia = 0.12 secs
Odin = 0.24 secs
V = 0.24 secs
Lua = 3.87 secs
Python (numba.njit) = 0.30 secs
Python (Pypy) = 0.42 secs
Python (exe) = 12.98 secs
Python = 7.74 secs
Ring = 12.82 secs
Ring (exe) = 28.67 secs
Go code with Go routines:
func nestedLoop() []int {
    var wg sync.WaitGroup
    var mu sync.Mutex
    aList := make([]int, 0)

    for x := 0; x < 10; x++ {
        wg.Add(1)
        go func(x int) {
            defer wg.Done()
            for y := 0; y < 1000; y++ {
                for z := 0; z < 10000; z++ {
                    if float64(z+x+y)/10 == float64(x) {
                        mu.Lock()
                        aList = append(aList, x)
                        mu.Unlock()
                    }
                }
            }
            fmt.Println(x)
        }(x)
    }

    wg.Wait()
    return aList
}

Clement

unread,
May 6, 2025, 5:30:00 AM5/6/25
to The Ring Programming Language
Tested this code and here is the results:

Ring = 6.09 secs
Python = 1.39 secs
Pypy = 0.16 secs
Julia = 0.15 secs
Go = 0.11 secs

// Measures how long it takes to compute the total count of primes under LIMIT
// Output: Found 78498 primes under 1000000 in x.xx seconds

func main() {

    LIMIT = 1_000_000

    start_time = clock()
    prime_count = count_primes(LIMIT)
    end_time = (clock() - start_time) / 1000

    print("Found #{prime_count} primes under #{LIMIT} in #{end_time} seconds.")

}

func is_prime(n) {
    if n < 2
        return false; ok
    if n = 2
        return true; ok
    if n % 2 = 0
        return false; ok
   
    for i = 3 to floor(sqrt(n)) step 2 {
        if n % i = 0
            return false
        ok
    }
    return true
}

func count_primes(limit) {
    count = 0
    for i = 2 to limit - 1 {
        if is_prime(i)
            count++
        ok
    }
    return count
}

Mahmoud Fayed

unread,
May 6, 2025, 9:18:19 PM5/6/25
to The Ring Programming Language
Hello Clement

This version is three times faster on my machine
The idea is to store the loop expression (maximum value) in a variable before the loop

// Measures how long it takes to compute the total count of primes under LIMIT
// Output: Found 78498 primes under 1000000 in x.xx seconds

func main() {

    LIMIT = 1_000_000

    start_time = clock()
    prime_count = count_primes(LIMIT)
    end_time = (clock() - start_time) / 1000

    print("Found #{prime_count} primes under #{LIMIT} in #{end_time} seconds.")

}

func is_prime(n) {
    if n < 2
        return false; ok
    if n = 2
        return true; ok
    if n % 2 = 0
        return false; ok
   
    nMax = floor(sqrt(n))
    for i = 3 to nMax step 2 {

        if n % i = 0
            return false
        ok
    }
    return true
}

func count_primes(limit) {
    count = 0
    nMax  = limit - 1
    for i = 2 to nMax {

        if is_prime(i)
            count++
        ok
    }
    return count
}

Results of my machine
Before update: 9 seconds
After update: 3 seconds

Greetings,
Mahmoud

Clement

unread,
May 6, 2025, 10:16:44 PM5/6/25
to The Ring Programming Language
Thanks Mahmoud for your code optimization magic!

Some optimization boost and now on average time is at 4.58 secs

Mahmoud Fayed

unread,
May 7, 2025, 12:03:34 AM5/7/25
to The Ring Programming Language
Hello Clement

You are welcome :D

Greetings,
Mahmoud

Clement

unread,
May 8, 2025, 10:56:20 AM5/8/25
to The Ring Programming Language
Tested this code, to create a populated list range from 1:50m and loop through this list adding 10 and timed the execution speed:

Ring = 15.98 secs
Python = 2.45 secs
Pypy = 0.17 secs
Julia = 0.20 secs
Go = 0.08 secs

# Ring
aList = 1:50_000_000

for i in aList {
    aList[i] += 10
}

# Python
    aList = list(range(1, 50_000_001))  
    aLen  = len(aList)

    for i in range(aLen):
        aList[i] += 10

# Julia using broadcast . operator
    aList = collect(1:50_000_000)

    bList = aList .+ 10     # adds 10 to each element

// Go
    aList := make([]int, 50_000_000)

    for i := range aList {
        aList[i] = i + 10
    }

Bert Mariani

unread,
May 8, 2025, 12:11:35 PM5/8/25
to The Ring Programming Language
Hello ALL

This shows the Difference between
     Huge List with Double Float numbers
     Huge Array with Integer

When its strictly Numbers  "Go"  with Array  -- Pun intended.

Mansour Ayouni

unread,
May 8, 2025, 12:44:14 PM5/8/25
to Bert Mariani, The Ring Programming Language
Hello Clement,

Never use for/in loop for large iteration because the for/next form id far more rapid:

image.png

Best,
Mansour

--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/ring-lang/95a4831a-171e-4726-91d7-8880f0c03eben%40googlegroups.com.

Mahmoud Fayed

unread,
May 8, 2025, 1:29:44 PM5/8/25
to The Ring Programming Language
Hello Clement

This is a version that uses RingFastPro

load "fastpro.ring"

t1    = clock()
nMax  = 50_000_000
aList = [ 0 ]
aList[1] = list(nMax)
updateList(aList,:serial,:row,1,0)
updateList(aList,:add,:row,1,10)

? (clock()-t1)/clocksPerSecond()

Time on my machine is less than 2 seconds ( 1.94)

Note: We will improve the :serial option in RingFastPro to work on the 1-D array too instead of using :row 

Greetings,
Mahmoud

Bert Mariani

unread,
May 8, 2025, 3:11:21 PM5/8/25
to The Ring Programming Language
Hello ALL

I get these Speed Times
1.52   1.58   1.68  with FastPro 
===========================

Modified Speed Calc --  when to Start Stop Clock
0.72  0.76  0.81

load "fastpro.ring"

nMax     = 50_000_000
aList    = [ 0 ]
aList[1] = list(nMax)

t1   = clock()

updateList(aList,:serial,:row,1,0)
updateList(aList,:add,:row,1,10)
t2   = clock()

Diff = t2 -t1
? Diff/clocksPerSecond()

Clement

unread,
May 8, 2025, 7:31:28 PM5/8/25
to The Ring Programming Language
ok, got it, this gives me 8.76 secs

for i = 1 to 50_000_000 {
    aList[i] += 10
}

Bert Mariani

unread,
May 9, 2025, 10:06:51 AM5/9/25
to The Ring Programming Language
Hello Clement, Mahmoud et ALL

All the Test is doing is filling a List of size nMax = 50_000_000 with a value 1..2..3..4  etc
See details below when using  a small  nMax = 10
See the  code for true comparison. 
Only need  updateList(aList,:serial,:row,1,2)  to do the same thing.

Time Result on my HP-i5 
FastPro  Time 0.26 secs   <<< A Lot Faster 35X
RING       Time 9.16 secs

========================
When seting nMax = 10

FastPro
Time 0 secs
      MatrixPrint: 1x10
|  3, 4, 5, 6, 7, 8, 9, 10, 11, 12 |

RING
Time 0 secs
11
12
13
14
15
16
17
18
19
20


=======================

load "fastpro.ring"
load "matrixlib.ring"

See nl+ "FastPro"+nl

nMax     = 50_000_000
aList    = [ 0 ]
aList[1] = list(nMax)

t1   = clock()
updateList(aList,:serial,:row,1,2)

t2   = clock()
Diff = t2 -t1

? "Time "+ Diff/clocksPerSecond() +" secs"
//MatrixPrint(aList)

//=======================
See nl+"RING"+nl
aList = 1:nMax  

t1   = clock()
for i = 1 to nMax
    aList[i] += 10
next

t2   = clock()
Diff = t2 -t1

? "Time "+ Diff/clocksPerSecond() +" secs"
//See aList


Mahmoud Fayed

unread,
May 10, 2025, 12:06:52 AM5/10/25
to The Ring Programming Language
Hello Bert

Thanks for sharing the results
RingFastPro performance is impressive :D

Greetings,
Mahmoud

Antonio F.S.

unread,
May 10, 2025, 5:24:32 AM5/10/25
to ring...@googlegroups.com
Hello colleagues.

An important question for me, since I am a, very keen user, with
strictly well organized documentation of any system, be it hardware or
software. Ring has such a remarkable feature among others.

Is everything concerning the Ring ecosystem also covered in your
official documentation (libraries, utilities, etc.)?

Best regards.
Antonio F.S.


Mahmoud Fayed

unread,
May 10, 2025, 6:53:30 AM5/10/25
to The Ring Programming Language
Hello Antonio

>> "Is everything concerning the Ring ecosystem also covered in your
official documentation (libraries, utilities, etc.)?"


Yes, the standard libraries/tools that are distributed with the language are documented.

There is always a space for improving documentation, also using AI like Windows Copilot, you can get description for and sample of Ring code.

There are external packages that could be installed using RingPM - These packages are distributed with it's own documentation.

Greetings,
Mahmoud

Antonio F.S.

unread,
May 10, 2025, 7:18:35 AM5/10/25
to ring...@googlegroups.com

Hello Mahmoud.

I understand and thank you for your answer, first of all.

I once asked what Softanza was and very kindly I was answered. But, I have not known to see in the documentation about it. Without being a member of this group, how could I have found out about it, is it already in the official Ring documentation?

Best regards.
Antonio F.S.

-------------------------------------------------------------------

El 10/5/25 a las 12:53, Mahmoud Fayed escribió:

Mahmoud Fayed

unread,
May 10, 2025, 7:23:57 AM5/10/25
to The Ring Programming Language
Hello Antonio

>> "Without being a member of this group, how could I have found out about it, is it already in the official Ring documentation?"


Also, in theory, without the group or using a search engine like google we can't discover everything.

Greetings,
Mahmoud

Antonio F.S.

unread,
May 10, 2025, 7:28:04 AM5/10/25
to ring...@googlegroups.com

Hi Mahmoud.
And wouldn't it be more complete to include a section in the official documentation presenting everything related to Ring, even if only the url? I say so, because that way we would know at first glance of the projects that are expanding the Ring ecosystem.

Thanks.
Best regards.
Antonio F.S.


------------------------------------------------------------------

El 10/5/25 a las 13:23, Mahmoud Fayed escribió:
Hello Antonio

Ka mara

unread,
May 10, 2025, 8:26:15 AM5/10/25
to Antonio F.S., ring...@googlegroups.com

"wouldn't it be more complete"

Indeed it would be nice, but basically some of those projects are still in development or awaiting official launch, that's why some their documentation has stalled


--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.

Antonio F.S.

unread,
May 11, 2025, 5:28:26 PM5/11/25
to Ka mara, ring...@googlegroups.com


Hello.

Everything is more complete when it is recognized that it is made up of each of its parts.

Ring could have a documentary area (as well as Nim and Gambas, for example), which would wisely welcome the more than necessary expansion of its own ecosystem. Harbour is a clear demonstration of dispersion and lack of confidence of the new developer collective, who could have done better than the usual ones (since Clipper), who are busy with their own business interests in which the important thing is that everything works; it has many tools but it is necessary to make a supreme effort of research to know that they exist and thus, to be able to know them. May Ring not make a similar mistake in this regard, is my best wish for this promising language.

Best regards.
Antonio F.S.

--------------------------------------------------------

El 10/5/25 a las 14:24, Ka mara escribió:

Mahmoud Fayed

unread,
May 12, 2025, 4:43:43 PM5/12/25
to The Ring Programming Language
Hello Antonio

Yes, we will share the packages list in Ring website at some point in the future.

Greetings,
Mahmoud

Antonio F.S.

unread,
May 12, 2025, 5:41:29 PM5/12/25
to ring...@googlegroups.com

Hello Mahmoud.

That's great news! :)-

I have seen Ring News from its inception in January 2016 to the present. There are extensions/utilities to consider and they certainly have an outstanding document base regarding what they are and their workings. That's what I was referring to, but organizing them so that they are closer at first glance. At the end of the day it is about recovering a collection of links because the rest is perfectly done. From there it would be a matter of bringing them together.

I am in awe of Ring's documentation. This is a great way to learn a programming language. :-) Let's see if from now on, when I'm freeing myself from professional projects, I can get more involved with Ring. I remember that I already made some steps with Ring a few years ago, but I couldn't continue due to lack of time. :-)

Thank you very much.
Best regards.
Antonio F.S.

--------------------------------------------------------------------

El 12/5/25 a las 22:43, Mahmoud Fayed escribió:

Mahmoud Fayed

unread,
May 13, 2025, 11:58:02 PM5/13/25
to The Ring Programming Language
Hello Antonio

You are welcome :D

Greetings,
Mahmoud

Reply all
Reply to author
Forward
0 new messages