// Console output utility
// - Doesn't serialize. It is by design

public class Cons
{
	public static int _ind_len = 0;
	public static StringBuilder _ind = new StringBuilder();

	public static void P(Object o) {
		if (_ind_len > 0) {
			System.out.println(o.toString().replaceAll("(?m)^", _ind.toString()));
		} else {
			System.out.println(o);
		}
	}

	// http://stackoverflow.com/questions/2925153/can-i-pass-an-array-as-arguments-to-a-method-with-variable-arguments-in-java
	public static void P(String fmt, Object... o) {
		P(String.format(fmt, o));
	}

	// nnl: no new line
	public static void Pnnl(Object o) {
		if (_ind_len > 0) {
			System.out.print(o.toString().replaceAll("(?m)^", _ind.toString()));
		} else {
			System.out.print(o);
		}
		System.out.flush();
	}

	public static void Pnnl(String fmt, Object... o) {
		Pnnl(String.format(fmt, o));
	}

	// MT: MeasureTime
	public static class MT implements AutoCloseable
	{
		//StackTraceElement _ste;
		long _start_time;

		public MT(String fmt, Object... o) {
			this(String.format(fmt, o));
		}

		public MT(String name) {
			//_ste = Thread.currentThread().getStackTrace()[2];
			P(name);
			_ind_len += 2;
			_ind.append("  ");
			_start_time = System.nanoTime();
		}

		@Override
		public void close() {
			double duration = (System.nanoTime() - _start_time) / 1000000.0;
			P(String.format("%.0f ms", duration));
			_ind_len -=2;
			_ind.setLength(_ind_len);

			//StringBuilder sb = new StringBuilder();
			//sb.append(Thread.currentThread().getId());
			//sb.append(" ");
			//sb.append(_ste.getClassName());
			//sb.append(".");
			//sb.append(_ste.getMethodName());
			//sb.append("()");
			//sb.append(" [");
			//sb.append(_ste.getFileName());
			//sb.append(":");
			//sb.append(_ste.getLineNumber());
			//sb.append("]");
			//System.err.printf("%s %f sec\n", sb.toString(), duration);
		}
	}
}

@@ -931,36 +931,8 @@
 %0A%09%7B%0A
-%09%09//StackTraceElement _ste;%0A
 %09%09lo
@@ -947,16 +947,16 @@
 t_time;%0A
+
 %0A%09%09publi
@@ -1055,63 +1055,8 @@
 ) %7B%0A
-%09%09%09//_ste = Thread.currentThread().getStackTrace()%5B2%5D;%0A
 %09%09%09P
@@ -1307,16 +1307,16 @@
 en -=2;%0A
+
 %09%09%09_ind.
@@ -1339,443 +1339,8 @@
 en);
-%0A%0A%09%09%09//StringBuilder sb = new StringBuilder();%0A%09%09%09//sb.append(Thread.currentThread().getId());%0A%09%09%09//sb.append(%22 %22);%0A%09%09%09//sb.append(_ste.getClassName());%0A%09%09%09//sb.append(%22.%22);%0A%09%09%09//sb.append(_ste.getMethodName());%0A%09%09%09//sb.append(%22()%22);%0A%09%09%09//sb.append(%22 %5B%22);%0A%09%09%09//sb.append(_ste.getFileName());%0A%09%09%09//sb.append(%22:%22);%0A%09%09%09//sb.append(_ste.getLineNumber());%0A%09%09%09//sb.append(%22%5D%22);%0A%09%09%09//System.err.printf(%22%25s %25f sec%5Cn%22, sb.toString(), duration);
 %0A%09%09%7D

clean up