π
<-
Chat plein-écran
[^]

[Eng][help needed] Calculator benchmarks

:32tins: :32tinsktpb: :32tinsktpn: :32tinscas: :32tinstpkc: :32tinstpktpb: :32tinstp: :32tinscastp: :32tinscmc: :32tinscx: :32tinscxcas:

Re: [Eng][help needed] Calculator benchmarks

Message non lude Lionel Debroux » 13 Sep 2013, 12:47

Ultranaiveprimes benchmark with N=1000 and N=10000, for TI-68k/AMS/GCC4TI

1) File ultranaiveprimes.c
Code: Tout sélectionner
// ultranaiveprimes.c: silly algorithm for finding primes

#define MIN_AMS 101
#define USE_TI89
#define USE_TI92P
#define USE_V200
#define USE_TI89T
#define NO_CALC_DETECT
#define OPTIMIZE_ROM_CALLS
#define RETURN_VALUE

#include <stdint.h>
#include <system.h>
#include <args.h>
#include <estack.h>
#include <intr.h>
#include <timath.h>

#define TIMER_START_VAL (100000UL)
#define N (10000)

void _main(void) {
    uint16_t j, k;
    short orig_rate = PRG_getRate();
    unsigned short orig_start = PRG_getStart();
    unsigned long val = 0;

    // Make the system timer an order of magnitude more precise;
    // NOTE: this code assumes a HW2+ TI-68k, i.e. anything since 1999.
    PRG_setRate(1); // Increment counter at a rate of 2^19/2^9 Hz
    PRG_setStart(0xCE); // Trigger the interrupt every 257 - 0xCE = 51 increments ~ 20.07 Hz.

    // The PRG_getStart() above effectively waited for the interrupt to trigger, so we don't need another wait.
    /*OSRegisterTimer(USER_TIMER, 1);
    while (!OSTimerExpired(USER_TIMER));
    OSFreeTimer(USER_TIMER);*/
    OSRegisterTimer(USER_TIMER, TIMER_START_VAL);

    // Main loop :)
    for (k = 3; k < N; k++) {
        for (j = 2; j < k - 1; j++) {
            if (k % j == 0) {
                j = k - 1; // so we exit from the inner for
            }
        }
    }

    // Retrieve timer value.
    val = TIMER_START_VAL - OSTimerCurVal(USER_TIMER);
    OSFreeTimer(USER_TIMER);

    // Push arguments onto the RPN stack: clean arguments up, then create a list.
    while (GetArgType (top_estack) != END_TAG) {
        top_estack = next_expression_index (top_estack);
    }
    top_estack--;
    push_longint(val);

    // Restore old system state.
    PRG_setRate(orig_rate);
    PRG_setStart(orig_start);
}


2) Compiler invocation
Code: Tout sélectionner
tigcc -v -O3 -Wall -W -mpcrel --optimize-code --cut-ranges --reorder-sections --remove-unused --merge-constants -fmerge-all-constants -Wa,--all-relocs -Wa,-l -fverbose-asm -save-temps -o unprimes ultranaiveprimes.c


3) Results on 89T HW4 AMS 3.10 patched with tiosmod+amspatch:
* N=1000: 25, 25, i.e. about 1"25.
* N=10000: 1918, 1919, i.e. ~1'35"6.
Membre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Avatar de l’utilisateur
Lionel DebrouxSuper Modo
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Prochain niv.: 11.2%
 
Messages: 6859
Inscription: 23 Déc 2009, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Classe: -
GitHub: debrouxl

Re: [Eng][help needed] Calculator benchmarks

Message non lude pier4r » 13 Sep 2013, 16:07

Thanks a lot! Now i'm porting the last bit of information about the savage benchmark (or at least what i found), then i'll report your results!

About the slow down of the Casio C program, i agree, in fact flyingfisch is working on it.
Avatar de l’utilisateur
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 15
Inscription: 11 Sep 2013, 16:12
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: [Eng][help needed] Calculator benchmarks

Message non lude pier4r » 13 Sep 2013, 19:12

Added. Now really i'm corious about nspire and nspire CX (if their cpu is different).
Avatar de l’utilisateur
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 15
Inscription: 11 Sep 2013, 16:12
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: [Eng][help needed] Calculator benchmarks

Message non lude Lionel Debroux » 13 Sep 2013, 20:05

The Nspire Clickpad/Touchpad on the one side, and the Nspire CX / CM on the other side, are indeed different. Their clock speed settings depend on the OS version, but the default value is higher for CX/CM than for the Clickpad/Touchpad, and overclocked CX/CM can reach higher clock speeds than Clickpad/Touchpad.
Membre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Avatar de l’utilisateur
Lionel DebrouxSuper Modo
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Prochain niv.: 11.2%
 
Messages: 6859
Inscription: 23 Déc 2009, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Classe: -
GitHub: debrouxl

Re: [Eng][help needed] Calculator benchmarks

Message non lude pier4r » 13 Sep 2013, 20:17

Oh, i don't know that. So i'll wait for their results (by you or by another volunteer).

PS: i don't have the TI here, but when i get it, i'll install your chess program. using the calculator also for relax seems good.
Avatar de l’utilisateur
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 15
Inscription: 11 Sep 2013, 16:12
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: [Eng][help needed] Calculator benchmarks

Message non lude pier4r » 15 Sep 2013, 21:42

I still have the hope for a volunteer with a ti-nspire!
Avatar de l’utilisateur
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 15
Inscription: 11 Sep 2013, 16:12
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

Re: [Eng][help needed] Calculator benchmarks

Message non lude Adriweb » 15 Sep 2013, 21:43

I guess I can help with Nspire-Lua :

Ultra Naive Prime :
Code: Tout sélectionner
local timerStart = timer.getMilliSecCounter()
local n = 100
for k = 3, n do
  for j = 2, k-1 do
    if k%j==0 then break end
  end
end

print("n = " .. n, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')


I'll report that tomorrow morning as I don't have my CX with me right now.
(It'll be on a CX CAS with OS 3.2.3, no overclock (default 133 MHz)).
Maybe on a not-overclock 3.1.0.392 CX CAS too.
Image

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14613
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: [Eng][help needed] Calculator benchmarks

Message non lude Adriweb » 15 Sep 2013, 22:23

Codes (one trivial and one optimized version) for Nspire-Lua Savage benchmark :
Code: Tout sélectionner
-- Non-optimized version :

local timerStart = timer.getMilliSecCounter()
local a = 0
for i = 1, 2500 do
    a = math.tan(math.atan(math.exp(math.log(math.sqrt(a*a))))) + 1
end
print("non-optimized", "n = 2500", " a = " .. a, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')


-- Optimized version :

local timerStart = timer.getMilliSecCounter()
local a = 0
-- localizing the functions speeds up the calculations in the loop.
local tan, atan, exp, log, sqrt = math.tan, math.atan, math.exp, math.log, math.sqrt
for i = 1, 2500 do
    a = tan(atan(exp(log(sqrt(a*a))))) + 1
end
print("  optimized  ", "n = 2500", " a = " .. a, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')
Image

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14613
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: [Eng][help needed] Calculator benchmarks

Message non lude Adriweb » 16 Sep 2013, 16:29

Okay, here are the results for Lua on the TI-Nspire CX CAS, not overclocked (default 133 MHz), OS 3.2.3 :

Image

The rest is coming later - Savage is talking a really long time, apparently...

Edit : savage-optimized takes 698.06 seconds for n=100... wut ?

Full code for all 3 :
Show/Hide spoilerAfficher/Masquer le spoiler
Code: Tout sélectionner
-- Some Benchmarks
-- Adrien "Adriweb" Bertrand
-- Sept. 15, 2013

outputs = {}
output = function(...) table.insert(outputs, table.concat({...}, " ; ")) end


-----------------------
-- Ultra Naive Prime --
-----------------------

function unp()
    for _,theN in pairs({100, 1000, 10000}) do
        local timerStart = timer.getMilliSecCounter()
        local n = theN
        for k = 3, n do
          for j = 2, k-1 do
            if k%j==0 then break end
          end
        end
        output("Ultra Naive Prime", "n = " .. n, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')
    end
    output ""
end

------------
-- Savage --
------------

function savage_unopti()
    -- Unoptimized version :
    local timerStart = timer.getMilliSecCounter()
    local a = 0
    for i = 1, 2500 do
        a = math.tan(math.atan(math.exp(math.log(math.sqrt(a*a))))) + 1
    end
    output("Savage ", " unoptimized  ", "n = 2500", " a = " .. a, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')
end

function savage_opti()
    -- Optimized version :
    local timerStart = timer.getMilliSecCounter()
    local a = 0
    -- localizing the functions speeds up the calculations in the loop.
    local tan, atan, exp, log, sqrt = math.tan, math.atan, math.exp, math.log, math.sqrt
    for i = 1, 2500 do
        a = tan(atan(exp(log(sqrt(a*a))))) + 1
    end
    output("Savage ", "   optimized   ", "n = 2500", " a = " .. a, (timer.getMilliSecCounter()-timerStart)/1000 .. ' s.')
end

function on.charIn(ch)
    pcall(({p=unp, u=savage_unopti, o=savage_opti})[ch])
    platform.window:invalidate()
end

function on.escapeKey()
    outputs = {}
    platform.window:invalidate()
end

function on.paint(gc)
    gc:setFont("sansserif", "r", 8)
    for i,v in ipairs(outputs) do
        gc:drawString(v, 5, 20*(i-1)+10, "top")
    end
end
Image

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
Avatar de l’utilisateur
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Prochain niv.: 80.2%
 
Messages: 14613
Images: 1218
Inscription: 01 Juin 2007, 00:00
Localisation: France
Genre: Homme
Calculatrice(s):
MyCalcs profile
Twitter/X: adriweb
GitHub: adriweb

Re: [Eng][help needed] Calculator benchmarks

Message non lude pier4r » 16 Sep 2013, 22:58

Thanks really a lot! Hopefully I will report those tomorrow.
Avatar de l’utilisateur
pier4r
Niveau 3: MH (Membre Habitué)
Niveau 3: MH (Membre Habitué)
Prochain niv.: 36%
 
Messages: 15
Inscription: 11 Sep 2013, 16:12
Genre: Non spécifié
Calculatrice(s):
MyCalcs profile

PrécédenteSuivante

Retourner vers Problèmes divers / Aide débutants

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 21 invités

-
Rechercher
-
Social TI-Planet
-
Sujets à la une
Comparaisons des meilleurs prix pour acheter sa calculatrice !
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
Phi NumWorks jailbreak
123
-
Faire un don / Premium
Pour plus de concours, de lots, de tests, nous aider à payer le serveur et les domaines...
Faire un don
Découvrez les avantages d'un compte donateur !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partenaires et pub
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1258 utilisateurs:
>1219 invités
>34 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Autres sites intéressants
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)