Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (487)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [FPS counter saying 980+?]  (Read 1828 times)
0 Members and 1 Guest are viewing this topic.
Offline GabrielBailey74
« Posted 2012-01-10 04:14:40 »

Just wondering, right now of course there's nothing really being drawn, just forcing a bar back and forth across the screen to catch lags.
But, it is telling me that the current fps is at 980+?

Here is the method, it's being called upon the first loop.
1  
2  
3  
4  
5  
6  
7  
8  
    public void updateFPS() {
      currentFPS ++;
        if (System.currentTimeMillis() - start >= 1000) {
            FPS = currentFPS;
            currentFPS = 0;
            start = System.currentTimeMillis();
        }
    }


1  
2  
3  
4  
    public void cycle() {
      updateFPS();
      System.out.println("FPS: "+FPS);
    }


Now I've made a couple of projects, and the FPS usually turns out from 20-70 highs of 140, so i'm thinking this is wrong, can someone confirm?
What should the average fps be?
Maximum, minimum, average?

Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #1 - Posted 2012-01-10 05:12:14 »

Your FPS method looks fine, so your count should be ok. Since you're not doing anything, it's reasonable to have such high fps.

By the way,   System.out.println() is really slow. you should just print it just before resetting the FPS counter. You'll probably see it increasing beyond 980.

Offline theagentd
« Reply #2 - Posted 2012-01-10 05:12:44 »

What? Only 980? System.out.println("FPS: "+FPS); is bottlenecking your application. Try to only print out the FPS once per second (move it to inside the if-statement in updateFPS()).

Myomyomyo.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GabrielBailey74
« Reply #3 - Posted 2012-01-10 05:16:27 »

Ah, thanks guys, now it's out printing every second, which as said does improve.
What is better higher fps, or lower?
>,<

Offline teletubo
« League of Dukes »

JGO Ninja


Medals: 48
Projects: 4
Exp: 8 years



« Reply #4 - Posted 2012-01-10 05:22:55 »

the higher, the quicker is your update/render loop which is a good thing (you don't have slow downs). however you'd want to limit it by Thread.sleep or Thread.yield to avoid your application consuming too much cpu (or to ensure it'll run the same speed in all computers if you're not using delta Time in your phyiscs/logic)

Offline GabrielBailey74
« Reply #5 - Posted 2012-01-10 05:25:48 »

Well see, it's not running off of a thread, it's running by:

1  
2  
      time = new Timer(1, this);
      time.start();


So..
Change that speed to 'limit' it, or go in the updateFPS, and limit it.
Or maybe that makes no sense thinking about it ._.

Offline theagentd
« Reply #6 - Posted 2012-01-10 05:38:08 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
public class FpsTest {
   public static void main(String[] args){
      int fpsCounter = 0;
      long nextUpdate = System.currentTimeMillis() + 1000;
      while(true){
         fpsCounter++;
         if(nextUpdate < System.currentTimeMillis()){
            System.out.println("FPS: " + fpsCounter);
            fpsCounter = 0;
            nextUpdate += 1000;
         }
      }
   }
}


Result:
1  
2  
3  
4  
5  
6  
FPS: 67548648
FPS: 67612529
FPS: 67327150
FPS: 67323088
FPS: 67275675
FPS: 67398851


THIS IS NORMAL! You're not doing anything, and you have a processor running at somewhere between 2-4 gigahertz. 67 612 529 "FPS" is nothing in this case. The slow part is checking the time (System.currentTimeMillis()).

Example: I have a processor running at about 2.8 GHz (stupid Turbo Boost changing it all the time). It managed about 67.76 million iterations per second. That's about 41 clock cycles per iteration of the loop. Stop worrying about your FPS already! Only ever worry about it if it's too low! xD

Myomyomyo.
Offline ReBirth
« Reply #7 - Posted 2012-01-10 13:23:00 »

I thought you had 1,000,000,000 sprites to render with huge AI computations for each of 1,000 entities and still get that FPS Grin

Offline theagentd
« Reply #8 - Posted 2012-01-10 13:26:47 »

I thought you had 1,000,000,000 sprites to render with huge AI computations for each of 1,000 entities and still get that FPS Grin
Sorry, did you say something? Well, it's not 1 billion sprites, but...

Myomyomyo.
Offline ReBirth
« Reply #9 - Posted 2012-01-10 13:38:49 »

@theagentd
thats 4 million sprites Smiley well if the sprite is 2x2 px, 1 billion is possible. (wait it's only dot!)

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline theagentd
« Reply #10 - Posted 2012-01-10 15:58:38 »

There's only about 2 MILLION (2 000 000) pixels on a 1080p screen, so why would you want 1 000 000 000 SPRITES in the first place? It would take 10 minutes to render a single frame with that many sprites due to a vertex bottleneck. -_-'

Sorry to derail the thread!

Myomyomyo.
Offline ra4king

JGO Kernel


Medals: 345
Projects: 2
Exp: 5 years


I'm the King!


« Reply #11 - Posted 2012-01-10 23:53:27 »

I have a 4.0GHz CPU, ran the FPS test = about 80 million FPS Cool

However, only 1 of my cores was being used. So I created 8 threads (for 8 logical cores) = 200-300 million FPS Cool

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

 

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

The first screenshot will be displayed as a thumbnail.

TehJavaDev (12 views)
2014-08-28 18:26:30

CopyableCougar4 (24 views)
2014-08-22 19:31:30

atombrot (37 views)
2014-08-19 09:29:53

Tekkerue (30 views)
2014-08-16 06:45:27

Tekkerue (29 views)
2014-08-16 06:22:17

Tekkerue (18 views)
2014-08-16 06:20:21

Tekkerue (28 views)
2014-08-16 06:12:11

Rayexar (65 views)
2014-08-11 02:49:23

BurntPizza (41 views)
2014-08-09 21:09:32

BurntPizza (33 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!