-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJankyframes.java
More file actions
141 lines (100 loc) · 4.23 KB
/
Copy pathJankyframes.java
File metadata and controls
141 lines (100 loc) · 4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import java.io.*;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import java.util.Scanner;
public class Jankyframes {
public static void frames (File file,FileWriter writer) throws IOException{
String word=" ";
String time1=" ";
long framecompleted=0;
long intended_vsync=0;
long time;
String int_vsync=" ";
String framcompleted="";
int k=0;
ArrayList<Long> arraylongList = new ArrayList<Long>();
int count=0;
int flag=0;
double dtime=0;
int num_frames=0;
long sum=0;
long totaldroppedframes=0;
Scanner scanObj=new Scanner(file);
while (scanObj.hasNextLine()) {
String line = scanObj.nextLine();
if (line.contains("---PROFILEDATA---")) {
line=scanObj.nextLine();
line =scanObj.nextLine();
while (!(line.contains("---PROFILEDATA---"))) {
if (line.charAt(0) == '0') {
String[] arrOflong = line.split(",", 17);
int_vsync = arrOflong[2];
framcompleted = arrOflong[13];
intended_vsync = Long.parseLong(int_vsync);
framecompleted = Long.parseLong(framcompleted);
time = framecompleted - intended_vsync;
dtime = (double) time / 1000000;
double rtime = Math.round(dtime * 10.0) / 10.0;
time1 = Double.toString(rtime);
arraylongList.add(time);
num_frames = arraylongList.size();
writer.write("intended_vsync ");
writer.write(int_vsync);
writer.write(" framecompleted ");
writer.write(framcompleted);
writer.write(" ");
writer.write("frame render duration ");
writer.write(" " + time1);
writer.write("\n");
}
line = scanObj.nextLine();
}
}
num_frames=arraylongList.size();
for(long a:arraylongList){
sum=sum+a;
}}
Long[] arr = new Long[arraylongList.size()];
arr = arraylongList.toArray(arr);
int size=arr.length;
for(int i=0;i<size-1;i++){
if((arr[i]>16)&&(arr[i+1]<16))
k++;
}
long last1 = arr[arraylongList.size()-1];
if(last1>16)
k++;
System.out.println("the number of droped durations "+k);
writer.write("the number of droped durations "+k);
writer.write("the number of continuous dropped frames "+count +"\n");
System.out.println("Total number of frames"+num_frames);
System.out.println("Total render duration "+sum);
System.out.println("total janked frames "+totaldroppedframes);
writer.close();
}
public static void main(String[] args) throws IOException, InterruptedException {
int i=0;
int j=0;
String inputString="";
while(!inputString.equals("exit")){
FileWriter writer= new FileWriter("file"+i+".txt");
Process process = Runtime.getRuntime().exec("\n" + " adb shell dumpsys gfxinfo glance.sample.standalone.xiaomi reset");
Process process1 = Runtime.getRuntime().exec("adb shell dumpsys gfxinfo glance.sample.standalone.xiaomi framestats ");
BufferedReader reader= new BufferedReader(new InputStreamReader(process1.getInputStream()));
String line;
while((line =reader.readLine())!= null){
writer.write(line+"\n");
}
writer.close();
Scanner scanner1 = new Scanner(System.in);
System.out.println("type exit to exit anything else to continue");
inputString = scanner1.nextLine();
TimeUnit.SECONDS.sleep(1);
i++;}
FileWriter writer= new FileWriter("printFrames.txt");
for(j=0;j<i;j++){
File file=new File("file" + j + ".txt");
frames(file,writer);
}
}
}