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)
2944 | #2cf7 | ^ | Idézet | Sat, 31 May 2014 22:51:19 +02
188.36.*.* Linux x86 Opera Classic Hungary *.catv.pool.telekom.hu
Kibenchmarkoltam én:
/* pidfind_tch */

#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

long int get_pid_by_process_name(char *pname)
{
	DIR *d;
	struct dirent *dir;
	FILE *f;
	char entry[24];
	char buf[256];
	long int l;

	d = opendir("/proc");
	if (d)
	{
		while ((dir = readdir(d)) != NULL)
		{
			strcpy(entry, "/proc/");
			strcat(entry, dir->d_name);
			strcat(entry, "/cmdline");
			f = fopen(entry, "rb");
			if (f != NULL)
			{
				fread(&buf[0], 1, 256, f);
				fclose(f);
				l = -1;
				while ((++l < 257) && (buf[l]) && (buf[l] != 32));
				buf[l] -= (buf[l] == 32) << 5;
				if (l)
				{
					while ((buf[--l] != 47) && l);
					l += (buf[l] == 47);
					if (!strcmp(pname, &buf[l]))
					{
						return atol(dir->d_name);
					}
				}
			}
		}
		return -1; /* nincs ilyen */
		closedir(d);
	}
	return -2; /* nem lehet megnyitni a /proc-ot */
}


int main(int argc, char *argv[])
{
	/*QCoreApplication a(argc, argv);*/

	int i;

	for (i = 0; i < 1000; ++i)
	{
		get_pid_by_process_name("konsole");
		get_pid_by_process_name("opera");
		get_pid_by_process_name("d3lphin");
		get_pid_by_process_name("mousepad");
	}

	return 0;
}
/* pidfind_kemi */

#include <QCoreApplication>
#include <QProcess>
#include <QStringList>
#include <stdio.h>

int getPID(QString processName)
{
	QProcess proc;
	QStringList args;
	args << "-c" << "ps aux | grep \"" + processName + "\" | grep \"root\"";
	proc.start("/bin/sh", args);
	proc.waitForFinished();
	QString s = proc.readLine();
	QStringList list = s.simplified().split(" ");
	if (list[0] != "root")
	{
		return -1;
	}
	return list[1].toInt();
}

int main(int argc, char *argv[])
{
	/*QCoreApplication a(argc, argv);*/

	int i;

	for (i = 0; i < 1000; ++i)
	{
		getPID("konsole");
		getPID("opera");
		getPID("d3lphin");
		getPID("mousepad");
	}

	return 0;
}
Tessék kemi. Ugyanaz a keret, ugyanúgy Qt5 fordítja, ugyanúgy 4 féle processt keres, ugyanúgy 1000x fut le, minden ugyanaz, csak a tiéd a ps-t és a grep-et hívogatja rendszerhívással, az enyém meg a /proc könyvtárat túrja. Eredmény:
root@Csabi:~/qtproj/build-pidfind-Desktop_Qt_5_3_0_GCC_64bit-Debug# time pidfind_tch

real    0m1.729s
user    0m0.264s
sys     0m1.424s
root@Csabi:~/qtproj/build-pidfind-Desktop_Qt_5_3_0_GCC_64bit-Debug# time pidfind_kemi

real    1m9.365s
user    0m23.216s
sys     0m29.176s
Az enyém 1729 ms alatt végzett, a tiéd 69365 ms alatt. A különbség 40x-es. (Nem is becsültem olyan rosszul, az előző postomban; nagyságrendileg stimmelt.)
Komment azt hiszem nem szükséges. Rövidebb kód != gyorsabb kód.


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!