Code example for Stack

Methods: isEmpty, peek, pop

0
        e.name = name;
        stack.push(e);
    } 
 
    public static void stop() { 
        if (stack.isEmpty()) return;
 
        StackElement e = stack.pop();
        long end = System.nanoTime();
        long dt = end - e.start;
 
        if (!stack.isEmpty()) {
            StackElement e2 = stack.peek();
            e2.internal += dt;
        } 
 
        long self = (dt - e.internal) / 1000; // in microseconds
        long total = dt / 1000;
 
        System.out.println("[PROF] {" + e.name + "} self: " + (self/1000F) + "ms, total: " + (total/1000F) + "ms");
    }