/** Statistics class for ray tracer performance numbers * Not a part of ray tracer, report generation only * Provides a single place for stats, rather than in several classes * Static for simplicity and global stats * TBD: stats per frame, camera? * @author: Phil Gage */ public class Statistics { // Pixel draw count for statistics static long pixelCount = 0; // Primary Rays // Ray count for statistics static long rayCount = 0; // Total Rays /** Intersection count for statistics, every object's intersect method must increment this */ // (could be per camera?) static long intersectionCount = 0; // Intersections static long totalStart = System.currentTimeMillis(); static long frameStart; /** * Start report for each frame. * @param frame input frame number */ public static void beginFrame (int frame) { frameStart = System.currentTimeMillis(); //tbd zero frame stats... } /** * Print report for each frame. * @param frame input frame number */ public static void endFrame (int frame) { double secs = (System.currentTimeMillis() - frameStart)/1000.0; System.out.println("Frame "+ frame + " secs: " + secs); //tbd print frame stats... } /** * Print report for total run. * @param world input World object */ public static void report (World world) { System.out.println ("Ray Tracing Report"); // Print stats double secs = (System.currentTimeMillis() - totalStart)/1000.0; System.out.println("Total secs: " + secs); if (world.grid != null) { System.out.println("Grid size= " + world.grid.size); // if (camera.bitmap != null) // System.out.println("Bitmap size=" + world.grid.size); // else // System.out.println("No bitmap"); } else System.out.println("No grid"); System.out.println("Primary Rays: " + pixelCount); System.out.println("Total Rays: " + rayCount); System.out.println("Intersections: " + intersectionCount); } }