load_file("rings.hoc")

mkrings(1, 6)

func doit() {local x
	mkrings($1, $2)
	print "run method = ", meth, "   rings = ", $1, "   cells/ring = ", $2
	//x = startsw()
	prtime()
	run()
	//x = startsw() - x
	x = prtime()
	return x
}

objref g2
g2 = new Graph()
objref f
f = new File()
proc family() {local nc, x, i
	meth = cvode_active()*(1 + cvode_local())
	g2.beginline()
	for i=0, 1000 { // will stop long before this
		nc = int(10*2^(i/2))
		x = doit($1, nc)
		print x
		g2.line(nc*$1, x)
		f.aopen("rings.dat")
		f.printf("%d %d %d %g\n", meth, $1, nc, x)
		f.close
		if (x > 300 || nc*$1 > 20000) { break }
	}
	g2.flush()
}

proc nfam() {local i
	for (i=1; i <= $1; i *= 2) {
		family(i)
	}
}


proc all() { local fac
	ns = $1
	fac = 2^int(log(1)/log(2)) // 0 when ns=1, 3 when ns = 10
	cvode_local(1)
	nfam(128*8/fac)
	cvode_active(0)
	nfam(16*8/fac)
	cvode_active(1)
	nfam(8*8/fac)
}

//all(10) // takes about 5 hours on 3GH linux machine when ns=10
//all(1) // about 7 hours