@@ -81,6 +81,7 @@ var traversePages = function () {
81
81
pages : {
82
82
tPages : 0 ,
83
83
newPages : 0 ,
84
+ missPages : 0 ,
84
85
} ,
85
86
} ,
86
87
fileMem = { } ;
@@ -90,30 +91,29 @@ var traversePages = function () {
90
91
var net = JSON . parse (
91
92
fs . readFileSync ( `${ program . base } /${ p } /network.json` , "utf8" )
92
93
) ;
93
- var trace = JSON . parse (
94
- fs . readFileSync ( `${ program . base } /${ p } /trace.json` , "utf8" )
95
- ) ;
94
+ // var trace = JSON.parse(
95
+ // fs.readFileSync(`${program.base}/${p}/trace.json`, "utf8")
96
+ // );
96
97
var netObj = netParser . parseNetworkLogs ( net ) ;
97
- var execTimings = traceParser . getExecutionTimingsByURL ( trace , net ) ;
98
+ // var execTimings = traceParser.getExecutionTimingsByURL(trace, net);
98
99
var graph = new dag . Graph ( netObj ) ;
100
+ var missOnPage = false ;
99
101
graph . createTransitiveEdges ( ) ;
100
102
var fetches = graph . transitiveEdges ;
101
103
summary . pages . tPages ++ ;
102
104
var jss = netObj . filter ( ( n ) => n . type && n . type . indexOf ( "script" ) != - 1 ) ;
103
105
for ( var n of jss ) {
104
106
summary . all . totalScripts ++ ;
105
107
var key = n . url . split ( "?" ) [ 0 ] ;
106
- fetches [ n . url ] &&
107
- fetches [ n . url ] . length &&
108
- summary . fetches . scriptsThatFetch ++ ;
108
+ var fCurr = fetches [ n . url ] ;
109
+ fCurr && fCurr . length && summary . fetches . scriptsThatFetch ++ ;
109
110
var unseenFile = false ;
110
- var timings = execTimings . get ( n . url ) ;
111
+ // var timings = execTimings.get(n.url);
111
112
112
113
if ( fileMem [ key ] ) {
113
114
var fPrev = fileMem [ key ] [ "fetches" ] ;
114
- var fCurr = fetches [ n . url ] ,
115
- execFound = null ;
116
- if ( fCurr && fCurr . length ) {
115
+ var execFound = null ;
116
+ if ( fCurr && fCurr . length && fPrev && fPrev . length ) {
117
117
execFound = sameFileFetches ( fPrev , fCurr , 1 ) ;
118
118
// localtotal++;
119
119
if ( execFound ) {
@@ -134,15 +134,26 @@ var traversePages = function () {
134
134
fCurr . sort ( )
135
135
) } `
136
136
) ;
137
+ missOnPage = true ;
137
138
}
138
139
139
- timings && ( fileMem [ key ] [ "timings" ] += addTimings ( timings ) ) ;
140
+ // timings && (fileMem[key]["timings"] += addTimings(timings));
141
+ } else if ( fCurr && fCurr . length ) {
142
+ fileMem [ key ] [ "fetches" ] . push ( fCurr ) ;
143
+ summary . fetches . fetchesDiff ++ ;
144
+ program . verbose &&
145
+ console . log (
146
+ `first time fetches for ${ n . url } : ${ JSON . stringify (
147
+ fCurr . sort ( )
148
+ ) } `
149
+ ) ;
150
+ summary . fetches . uniqueScriptsThatFetch ++ ;
140
151
}
141
152
} else {
142
153
summary . all . uniqueScripts ++ ;
143
154
unseenFile = true ;
144
155
fileMem [ key ] = { } ;
145
- fileMem [ key ] [ "timings" ] = timings ? addTimings ( timings ) : 0 ;
156
+ // fileMem[key]["timings"] = timings ? addTimings(timings) : 0;
146
157
var f = ( fileMem [ key ] [ "fetches" ] = [ ] ) ,
147
158
_f = fetches [ n . url ] ;
148
159
_f && _f . length && f . push ( _f ) ;
@@ -155,16 +166,17 @@ var traversePages = function () {
155
166
) ;
156
167
}
157
168
}
169
+ if ( missOnPage ) summary . pages . missPages ++ ;
158
170
if ( unseenFile ) summary . pages . newPages ++ ;
159
171
// console.log(`per page fetch: ${localfetched} ${localtotal}`);
160
172
} catch ( e ) {
161
173
program . verbose && console . log ( e ) ;
162
174
}
163
175
}
164
- for ( var f in fileMem ) {
165
- console . log ( `${ f } ,${ fileMem [ f ] [ "timings" ] } ` ) ;
166
- }
167
- // console.log(JSON.stringify(summary, null, 2));
176
+ // for (var f in fileMem) {
177
+ // console.log(`${f},${fileMem[f]["timings"]}`);
178
+ // }
179
+ console . log ( JSON . stringify ( summary , null , 2 ) ) ;
168
180
} ;
169
181
170
182
traversePages ( ) ;
0 commit comments