Game loop help

Hey everyone, I’ve just gotten started with java game development and i though that I’d create a simple space invaders clone to start off with. I’ve created an update and render loop and managed to render a sprite to the screen.

While i was first creating the game loop it updated 60 times per second as i was expecting and i was getting a bunch of fps. But now when I’ve started adding stuff to the render function of my game it only updates at around 55-59 times a second.

Sure this isn’t huge performance hit but i would like to know what causes this.

So if anyone feels like looking at the code here it is:

       int frames = 0;
		int ticks = 0;
		double targetTickTime = 1000000000 / 60;
		double lastUpdateTime = System.nanoTime();
		double lastFPSPrintTime = System.nanoTime();

		while (running) {
			double nowTime = System.nanoTime();
			if (nowTime - lastUpdateTime >= targetTickTime) {
				ticks++;
				tick();
				lastUpdateTime = System.nanoTime();
			}
			if (nowTime - lastFPSPrintTime >= 1000000000) {
				System.out.println("Updates: " + ticks + ", Frames: " + frames);
				ticks = 0;
				frames = 0;
				lastFPSPrintTime = System.nanoTime();
			}
			render();
			frames++;
		}