Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (404)
games submitted by our members
Games in WIP (289)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  So now we're on a microbenchmarking spree  (Read 3629 times)
0 Members and 1 Guest are viewing this topic.
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #30 - Posted 2004-04-28 06:37:04 »

Uh uh diggin up a dead thread Smiley

There is a little glitch in the Test class. public void math() uses a long for the result (instead of a double). The massive amount of casting makes it ~25% slower than it has to be. Before it was 1:6 and now it's about 1:4.5.

Well, Math got faster and FMath isn't "17.6 times faster than Math" anymore, but it's still faster and might be a measurable difference in your application.

弾幕 ☆ @mahonnaiseblog
Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #31 - Posted 2004-04-28 15:06:05 »

Hmmm, I'm quite sure I fixed that when I measured it. I print the results and they were approx. the same. Lemme run it again  Smiley

Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #32 - Posted 2004-04-29 12:35:31 »

I checked and re-ran the benchmark.
On the client, I'm getting FMath being ~6.2 times as fast, on the server about ~22.8 times as fast.

This is on 1.4.2_03

[EDIT:]
BTW, it's of course not really a comparitive test since Math obviously has far greater precision but it might indicate what kind of performance you could gain by settling for slightly inaccurate results.
That said, I suggest to always use Math, and switch to something like FMath if (after profiling) it's clear that Math causes a major bottleneck and that FMath's inaccuracies are within bounds of acceptability.

Games published by our own members! Check 'em out!
Play the free demo of Revenge of the Titans!
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #33 - Posted 2004-04-29 18:00:26 »

Quote
[...]
That said, I suggest to always use Math, and switch to something like FMath if (after profiling) it's clear that Math causes a major bottleneck and that FMath's inaccuracies are within bounds of acceptability.


Yea, of corse Smiley

In my current case I'll only have one class wich uses some basic math relativly often. Therefore I can just try it out without too much hassle.

One thing wich is rather odd: with C/C++ lookup tables are slower then doing it the proper way, because lookup tables needs to execute more commands. Well, it's more inaccurate than the über accurate java way in double precision. I wish there would be a float math lib and a hotspot compiler wich knows about it, too.

That would be pretty awesome Smiley

弾幕 ☆ @mahonnaiseblog
Offline erikd

JGO Knight


Medals: 3
Projects: 3


Maximumisness


« Reply #34 - Posted 2004-04-29 23:35:27 »

I think many things are slower to do using look-up tables these days (CPU's being much faster than memory), unless they are very processor intensive tasks. Especially in java, because of its bounds checks.
In the old days I used look-up tables everywhere. Now only in some circumstances.
And yes, a fast, less accurate Math lib like you described (or a even a switch) would be awesome.
I wish nobody noticed java's slight 'inaccuracy' with sin/cos in 1.3  Grin

Pages: 1 [2]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Get high quality music tracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (20 views)
2013-05-17 21:29:12

alaslipknot (32 views)
2013-05-16 21:24:48

gouessej (62 views)
2013-05-16 00:53:38

gouessej (61 views)
2013-05-16 00:17:58

theagentd (71 views)
2013-05-15 15:01:13

theagentd (65 views)
2013-05-15 15:00:54

StreetDoggy (105 views)
2013-05-14 15:56:26

kutucuk (129 views)
2013-05-12 17:10:36

kutucuk (129 views)
2013-05-12 15:36:09

UnluckyDevil (138 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.105 seconds with 20 queries.