English | Magyar
JS ki | CSS ki | Ékezetek ki | HiContrast
Lapozó:  (0 - 1428) 
<== | ==>
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.12.02. 21:02)
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

kemi  (statz) Főfasz
#2, Főfasz (2970)
4356 | #2460 | ^ | Idézet | Sun, 17 Mar 2013 22:24:36 +01
94.21.*.* Linux x86 Google Chrome Hungary *.pool.digikabel.hu
Ugyanaz a teszt, OOP vs imperatív megoldás, default, meg -O3 kapcsolókkal fordítva:

rnd2.h
#ifndef RND2_H_
#define RND2_H_

void srnd2(unsigned long int seed);
unsigned long int rnd2();

#endif

rnd2.cpp
unsigned long int __seed0, __seed1, __seed2, __seed3;

unsigned long int __rol(unsigned long int value, unsigned char offset)
{
	offset = offset & 0x1f;
	return (value << offset) | (value >> (0x20 - offset));
}

unsigned long int __ror(unsigned long int value, unsigned char offset)
{
	offset = offset & 0x1f;
	return (value >> offset) | (value << (0x20 - offset));
}

void srnd2(unsigned long int seed)
{
	__seed0 = seed;
	__seed1 = __seed0 ^ 0xaaaaaaaa;
	__seed1 = __rol(__seed1 >> 11, __seed1);
	__seed1 = __seed1 ^ (__seed1 >> 21);
	__seed2 = __seed0 ^ 0x55555555;
	__seed2 = __ror(__seed2 << 6, __seed2);
	__seed2 = __seed2 ^ (__seed2 >> 22);
	__seed3 = (__seed2 << 16) | (__seed1 >> 16);
}

unsigned long int rnd2()
{
	__seed1 = __rol(__seed1, 5);
	__seed2 = __ror(__seed2, 9);
	__seed0 = __rol(__seed0, 11);
	__seed0 ^= __seed1;
	__seed0 ^=  __rol(__seed1, 8) << 11;
	__seed0 ^= __ror(__seed2, 8) & 63;
	__seed0 ^= __rol(__seed3, 8) >> 5;
	__seed0 = __ror(__seed0, 14);
	__seed0 ^= __seed3;
	__seed1 ^= __seed3;
	__seed2 ^= __seed3;
	__seed3 = __ror(__seed3, __seed0);
	return __seed0;
}

imp.cpp
#include <cstdlib>
#include <ctime>
#include "rnd2.h"

int main() {
    srnd2(time(NULL));
    int table[256];
    int i, j, k, r, temp;
    for (i = 0; i < 1000; i++) {
	for (j = 0; j < 1000; j++) {
	    for (k = 0; k < 256; k++) table[k] = k;
	    for (k = 0; k < 256; k++) {
		r = rnd2() & 255;
		temp = table[r];
		table[k] = temp;
	    }
	}
    }
    return 0;
}


CRnd2.h
#ifndef CRND2_H_
#define CRND2_H_

class CRnd2 {
public:
    void srnd2(unsigned long int seed);
    unsigned long int rnd2();
private:
    unsigned long int __seed0;
    unsigned long int __seed1;
    unsigned long int __seed2;
    unsigned long int __seed3;

    unsigned long int __rol(unsigned long int value, unsigned char offset);
    unsigned long int __ror(unsigned long int value, unsigned char offset);

};

#endif

CRnd2.cpp
#include "CRnd2.h"

unsigned long int CRnd2::__rol(unsigned long int value, unsigned char offset)
{
	offset = offset & 0x1f;
	return (value << offset) | (value >> (0x20 - offset));
}

unsigned long int CRnd2::__ror(unsigned long int value, unsigned char offset)
{
	offset = offset & 0x1f;
	return (value >> offset) | (value << (0x20 - offset));
}

void CRnd2::srnd2(unsigned long int seed)
{
	__seed0 = seed;
	__seed1 = __seed0 ^ 0xaaaaaaaa;
	__seed1 = __rol(__seed1 >> 11, __seed1);
	__seed1 = __seed1 ^ (__seed1 >> 21);
	__seed2 = __seed0 ^ 0x55555555;
	__seed2 = __ror(__seed2 << 6, __seed2);
	__seed2 = __seed2 ^ (__seed2 >> 22);
	__seed3 = (__seed2 << 16) | (__seed1 >> 16);
}

unsigned long int CRnd2::rnd2()
{
	__seed1 = __rol(__seed1, 5);
	__seed2 = __ror(__seed2, 9);
	__seed0 = __rol(__seed0, 11);
	__seed0 ^= __seed1;
	__seed0 ^=  __rol(__seed1, 8) << 11;
	__seed0 ^= __ror(__seed2, 8) & 63;
	__seed0 ^= __rol(__seed3, 8) >> 5;
	__seed0 = __ror(__seed0, 14);
	__seed0 ^= __seed3;
	__seed1 ^= __seed3;
	__seed2 ^= __seed3;
	__seed3 = __ror(__seed3, __seed0);
	return __seed0;
}

oop.cpp
#include <cstdlib>
#include <ctime>
#include "CRnd2.h"

int main() {
    CRnd2 rnd = CRnd2();
    rnd.srnd2(time(NULL));
    int table[256];
    int i, j, k, r, temp;
    for (i = 0; i < 1000; i++) {
	for (j = 0; j < 1000; j++) {
	    for (k = 0; k < 256; k++) table[k] = k;
	    for (k = 0; k < 256; k++) {
		r = rnd.rnd2() & 255;
		temp = table[r];
		table[k] = temp;
	    }
	}
    }
    
    return 0;
}


kemi242@linuxmint ~/a $ time ./imp

real	0m21.088s
user	0m21.077s
sys	0m0.004s
kemi242@linuxmint ~/a $ time ./imp_O3

real	0m2.430s
user	0m2.424s
sys	0m0.000s
kemi242@linuxmint ~/a $ time ./oop

real	0m29.269s
user	0m29.266s
sys	0m0.000s
kemi242@linuxmint ~/a $ time ./oop_O3

real	0m2.454s
user	0m2.444s
sys	0m0.004s
kemi242@linuxmint ~/a $ 
Úgy látszik, az O3 kapcsoló nagyrészt kioptimalizálja az OOP hátrányait, ahol tudja.


English | Magyar
JS ki | CSS ki | Ékezetek ki | HiContrast
Lapozó:  (0 - 1428) 
<== | ==>
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.12.02. 21:02)
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!