Index: tools/perf/process_stat_array.py
===================================================================
--- tools/perf/process_stat_array.py	(revision 1cc76897009fde80a172b634a4b8c0add28d4749)
+++ tools/perf/process_stat_array.py	(revision eb9c2dcc0d5838c321d630d193f093b3f35d9d32)
@@ -1,5 +1,7 @@
 #!/usr/bin/python3
 
-import argparse, os, sys, re
+import argparse, json, math, os, sys, re
+from PIL import Image
+import numpy as np
 
 def dir_path(string):
@@ -11,4 +13,5 @@
 parser = argparse.ArgumentParser()
 parser.add_argument('--path', type=dir_path, default=".cfadata", help= 'paste path to biog.txt file')
+parser.add_argument('--out', type=argparse.FileType('w'), default=sys.stdout)
 
 try :
@@ -23,4 +26,9 @@
 counters = {}
 
+max_cpu = 0
+min_cpu = 1000000
+max_tsc = 0
+min_tsc = 18446744073709551615
+
 #open the files
 for filename in filenames:
@@ -31,12 +39,31 @@
 		with open(os.path.join(root, filename), 'r') as file:
 			for line in file:
-				# data = [int(x.strip()) for x in line.split(',')]
-				data = [int(line.strip())]
-				data = [me, *data]
+				raw = [int(x.strip()) for x in line.split(',')]
+
+				## from/to
+				high = (raw[1] >> 32)
+				low  = (raw[1] & 0xffffffff)
+				data = [me, raw[0], high, low]
+				max_cpu = max(max_cpu, high, low)
+				min_cpu = min(min_cpu, high, low)
+
+				## number
+				# high = (raw[1] >> 8)
+				# low  = (raw[1] & 0xff)
+				# data = [me, raw[0], high, low]
+				# max_cpu = max(max_cpu, low)
+				# min_cpu = min(min_cpu, low)
+
+
+				max_tsc = max(max_tsc, raw[0])
+				min_tsc = min(min_tsc, raw[0])
 				merged.append(data)
 
-	except:
+	except Exception as e:
+		print(e)
 		pass
 
+
+print({"max-cpu": max_cpu, "min-cpu": min_cpu, "max-tsc": max_tsc, "min-tsc": min_tsc})
 
 # Sort by timestamp (the second element)
@@ -47,25 +74,71 @@
 merged.sort(key=takeSecond)
 
-# for m in merged:
-# 	print(m)
+json.dump({"values":merged, "max-cpu": max_cpu, "min-cpu": min_cpu, "max-tsc": max_tsc, "min-tsc": min_tsc}, args.out)
 
-single = []
-curr = 0
+# vmin = merged[ 0][1]
+# vmax = float(merged[-1][1] - vmin) / 2500000000.0
+# # print(vmax)
 
-# merge the data
-# for (me, time, value) in merged:
-for (me, value) in merged:
-	# check now much this changes
-	old = counters[me]
-	change = value - old
-	counters[me] = value
+# bins = []
+# for _ in range(0, int(math.ceil(vmax * 10))):
+# 	bins.append([0] * (32 * 32))
 
-	# add change to the current
-	curr = curr + change
-	single.append( value )
+# # print(len(bins))
+# bins = np.array(bins)
 
-	pass
+# rejected = 0
+# highest  = 0
 
-print(single)
+# for x in merged:
+# 	b = int(float(x[1] - vmin) / 250000000.0)
+# 	from_ = x[2]
+# 	if from_ < 0 or from_ > 32:
+# 		rejected += 1
+# 		continue;
+# 	to_   = x[3]
+# 	if to_ < 0 or to_ > 32:
+# 		rejected += 1
+# 		continue;
+# 	idx = (to_ * 32) + from_
+# 	bins[b][idx] = bins[b][idx] + 1
+# 	highest = max(highest, bins[b][idx])
+
+# bins = np.array(map(lambda x: np.int8(x * 255.0 / float(highest)), bins))
+
+# print([highest, rejected])
+# print(bins.shape)
+
+# im = Image.fromarray(bins)
+# im.save('test.png')
+
+# vmax = merged[-1][1]
+
+# diff = float(vmax - vmin) / 2500000000.0
+# print([vmin, vmax])
+# print([vmax - vmin, diff])
+
+# print(len(merged))
+
+# for b in bins:
+# 	print(b)
+
+# single = []
+# curr = 0
+
+# # merge the data
+# # for (me, time, value) in merged:
+# for (me, value) in merged:
+# 	# check now much this changes
+# 	old = counters[me]
+# 	change = value - old
+# 	counters[me] = value
+
+# 	# add change to the current
+# 	curr = curr + change
+# 	single.append( value )
+
+# 	pass
+
+# print(single)
 
 # single = sorted(single)[:len(single)-100]
