English | Magyar
JS ki | CSS ki | Ékezetek ki | HiContrast
Lapozó:  (0 - 1424) 
<== | ==>
Ugrás a végére | Összes megjelenítése | Utolsó oldal
OpenOpera patches | Opera-SSL patches | Opera 12.15 source (Git repository) | Opera 12.15 source (Torrent) | Opera internal pages | Otter Browser Linux x64 - Qt5.15.2/QtWebKit5.602.1 (2024.04.27. 20:05)
OS for MC680x0 | OS for PPC | OS for Sparc64 | besztofbégéaefcé | CSÉNDZSLOG | WebToolz | DDG Shit Filter | Google Shit Filter | Progz | Fast CSS Box | Browser | OS | Agent | Statisztika | BBCode
Monospace font-family: Courier New | Browser default monospace
Email értesítő / Email notification ===> 
Keresés
Σ: 1 post

TCH  (statz) Főfasz
#1, Főfasz (10443)
3578 | #1778 | ^ | Idézet | Sun, 30 Oct 2011 18:29:58 +01
46.107.*.* Unknown Unknown Hungary *.catv.pool.telekom.hu
Gondoltam kitesztelem, melyik a jobb, a Linux véletlenszámgenerátora, vagy amit tegnap írtam.
Két dolgot vizsgáltam, a sebességet és az ismétlés nélkül legenerált számok mennyiségét.

rndtest.c:
void main()
{
	int i;
	for (i = 0; i < 500000000; ++i) rand();
}
rndtest1.c:
#include "rnd1.c"

void main()
{
	int i;
	for (i = 0; i < 500000000; ++i) rnd1();
}
Eredmény:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# time ./a.out

real    0m14.109s
user    0m14.097s
sys     0m0.008s
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# time ./a.out

real    0m22.426s
user    0m22.417s
sys     0m0.008s
Vagyis 22426/14109=1.58948, azaz a Linux, illetve a libc véletlenszámgenerátora ~60%-al gyorsabb.

Viszont a másik tesztben:
rndtest.c:
void main()
{
	srand(0);
	int i, j;
	unsigned int l;
	unsigned int tbl[1048576];
	for (i = 0; i < 1048576; ++i)
	{
		l = rand();
		for (j = 0; j < i; ++j)
		{
			if (l == tbl[j])
			{
				printf("%d\n", i);
				return;
			}
		}
		tbl[i] = l;
	}
}
rndtest1.c
#include "rnd1.c"

void main()
{
	__seed = 0;
	int i, j;
	unsigned int l;
	unsigned int tbl[1048576];
	for (i = 0; i < 1048576; ++i)
	{
		l = rnd1();
		for (j = 0; j < i; ++j)
		{
			if (l == tbl[j])
			{
				printf("%d\n", i);
				return;
			}
		}
		tbl[i] = l;
	}
}
Eredmény:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
15357
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
104930
0:1
0xb11193c1 seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
102640
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
60108
1:1
0xfa52fe7 seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
41026
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
51688
1:2
0xffffffff seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
53585
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
49037
2:2
1 seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
15357
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
12663
3:2
4743463 seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
46003
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
101904
3:3
0x986fae83 seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
80668
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
40103
4:3
982357 seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
56884
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
104361
4:4
986739687 seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
62171
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
51499
5:4
666 seed értékkel:
root@Csabi:~# gcc rndtest.c -O3
root@Csabi:~# ./a.out
43118
root@Csabi:~# gcc rndtest1.c -O3
root@Csabi:~# ./a.out
58930
5:5
Az eredmény döntetlen, ha a menetek számát nézzük. Viszont, ha az összértéket (osztva 10-el az átlag), akkor:
rand(): 015357+102640+041026+053585+015357+046003+080668+056884+062171+043118=516809
rnd1(): 104930+060108+051688+049037+012663+101904+040103+104361+051499+058930=635223
635223/516809=1.22913 azaz a mi véletlenszámgenerátorunk ~23%-al precízebb, mint a Linuxé.

Hát ezt úgy is lehet nézni, hogy a Linuxé nagyobb sebességkülönbséget ad, mint amekkora precizitáskülönbséget a miénk, de úgy is, hogy itt a precizitás szerintem fontosabb. :P

A saját konklúzióját majd mindenki magának.


English | Magyar
JS ki | CSS ki | Ékezetek ki | HiContrast
Lapozó:  (0 - 1424) 
<== | ==>
Ugrás a végére | Összes megjelenítése | Utolsó oldal
OpenOpera patches | Opera-SSL patches | Opera 12.15 source (Git repository) | Opera 12.15 source (Torrent) | Opera internal pages | Otter Browser Linux x64 - Qt5.15.2/QtWebKit5.602.1 (2024.04.27. 20:05)
OS for MC680x0 | OS for PPC | OS for Sparc64 | besztofbégéaefcé | CSÉNDZSLOG | WebToolz | DDG Shit Filter | Google Shit Filter | Progz | Fast CSS Box | Browser | OS | Agent | Statisztika | BBCode
Monospace font-family: Courier New | Browser default monospace
Email értesítő / Email notification ===> 
Keresés

Név: (max 255 byte)

Email: (max 255 byte) Nem kötelező!

Üzenet: (max 65536 kar.) 65536-0=65536




crap_vkn v4.34.0 by TCH
Thx to saxus for the escaped string decoder function (PHP), the realIP function (PHP) & the SQL handle layer (PHP), to thookerov for the int_divide function (PHP), to Jeff Anderson for the getSelText function (JS), to Alex King for the insertAtCursor function (JS), Flood3r for the new CSS styles, Pety for the spamprotection idea and some design and comfort ideas, MaxMind for the IP2Country database, famfamfam for the flags of countries and an unknown PHP programmer for the removeAccents function.



Kecskebaszók ide!