🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.java
Article #154042

Re: Prędkość Java kontra C#

#154042
From: Borneq
Date: Tue, 15 Jul 2014 17:42
41 lines
1981 bytes
W dniu 2014-07-14 09:36, Borneq pisze:
> W Javie i C# mocno użyte są obiekty, zamiast tylko wołania procedury
> tworzony obiekt, który dalej to wykonuje. Może Java ma szybszą alokację
> pamięci niż C#?
Zrobiłem program testowy:
	public static boolean arith(int x,int y)
	{
		for (int i=0; i<4; i++)
		{
			double d = (double)(x+y+i)/(x*x+y*y);
			x = (int)(y+d);
			y = (int)(x+d);
		}		
		return x>y;
	}


i dla odmiany wersja z częstą alokacją:
public class Obj {
	int x,y;
	public Obj(int _x, int _y)
	{
		x = _x; y=_y;
	}
	public boolean arith() //dalej to samo

Zmierzony czas w Javie:
static:
time=63,585769 cnt=0
create objects:
time=149,328919 cnt=0

W C#:
static:
time=112.044840926103 cnt=0
create objects:
time=142.498710248631 cnt=0

Znowu zaskoczenie, z tworzeniem obiektów C# radzi sobie nawet lepiej niż 
Java, ale gorzej ze zwykłą arytmetyką. Choć w moim algorytmie była 
jeszcze większa różnica na niekorzyść C#
Technical Details
Message-ID: <lq3p5v$iff$1@node2.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
References: <lpv1t6$363$1@node2.news.atman.pl> <lpv236$363$2@node2.news.atman.pl> <lq002d$3i7$1@news.dialog.net.pl> <lq01a6$u1c$1@node2.news.atman.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Borneq <borneq@antyspam.hidden.pl>
Newsgroups: pl.comp.lang.java
Subject: Re: Prędkość Java kontra C#
Date: Tue, 15 Jul 2014 19:42:20 +0200
Organization: ATMAN - ATM S.A.
Lines: 41
Message-ID: <lq3p5v$iff$1@node2.news.atman.pl>
References: <lpv1t6$363$1@node2.news.atman.pl> <lpv236$363$2@node2.news.atman.pl> <lq002d$3i7$1@news.dialog.net.pl> <lq01a6$u1c$1@node2.news.atman.pl>
NNTP-Posting-Host: 91.239.205.62
Mime-Version: 1.0
X-Trace: node2.news.atman.pl 1405446143 18927 91.239.205.62 (15 Jul 2014 17:42:23 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Tue, 15 Jul 2014 17:42:23 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To: <lq01a6$u1c$1@node2.news.atman.pl>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit