OLD | NEW |
1 -- Generate n-grams of Skia API calls from SKPs. | 1 -- Generate n-grams of Skia API calls from SKPs. |
2 | 2 |
3 -- To test this locally, run: | 3 -- To test this locally, run: |
4 -- $ GYP_DEFINES="skia_shared_lib=1" make lua_pictures | 4 -- $ GYP_DEFINES="skia_shared_lib=1" make lua_pictures |
5 -- $ out/Debug/lua_pictures -q -r $SKP_DIR -l tools/lua/ngrams.lua > /tmp/lua-ou
tput | 5 -- $ out/Debug/lua_pictures -q -r $SKP_DIR -l tools/lua/ngrams.lua > /tmp/lua-ou
tput |
6 -- $ lua tools/lua/ngrams_aggregate.lua | 6 -- $ lua tools/lua/ngrams_aggregate.lua |
7 | 7 |
8 -- To run on Cluster Telemetry, copy and paste the contents of this file into | 8 -- To run on Cluster Telemetry, copy and paste the contents of this file into |
9 -- the box at https://skia-tree-status.appspot.com/skia-telemetry/lua_script, | 9 -- the box at https://skia-tree-status.appspot.com/skia-telemetry/lua_script, |
10 -- and paste the contents of ngrams_aggregate.lua into the "aggregator script" | 10 -- and paste the contents of ngrams_aggregate.lua into the "aggregator script" |
11 -- box on the same page. | 11 -- box on the same page. |
12 | 12 |
13 -- Change n as desired. | 13 -- Change n as desired. |
| 14 -- CHANGEME |
14 local n = 3 | 15 local n = 3 |
| 16 -- CHANGEME |
15 | 17 |
16 -- This algorithm uses a list-of-lists for each SKP. For API call, append a | 18 -- This algorithm uses a list-of-lists for each SKP. For API call, append a |
17 -- list containing just the verb to the master list. Then, backtrack over the | 19 -- list containing just the verb to the master list. Then, backtrack over the |
18 -- last (n-1) sublists in the master list and append the verb to those | 20 -- last (n-1) sublists in the master list and append the verb to those |
19 -- sublists. At the end of execution, the master list contains a sublist for | 21 -- sublists. At the end of execution, the master list contains a sublist for |
20 -- every verb in the SKP file. Each sublist has length n, with the exception of | 22 -- every verb in the SKP file. Each sublist has length n, with the exception of |
21 -- the last n-1 sublists, which are discarded in the summarize() function, | 23 -- the last n-1 sublists, which are discarded in the summarize() function, |
22 -- which generates counts for each n-gram. | 24 -- which generates counts for each n-gram. |
23 | 25 |
24 local ngrams = {} | 26 local ngrams = {} |
(...skipping 29 matching lines...) Expand all Loading... |
54 counts[ngram] = counts[ngram] + 1 | 56 counts[ngram] = counts[ngram] + 1 |
55 end | 57 end |
56 end | 58 end |
57 end | 59 end |
58 | 60 |
59 -- Write out code for aggregating. | 61 -- Write out code for aggregating. |
60 for ngram, count in pairs(counts) do | 62 for ngram, count in pairs(counts) do |
61 io.write("if counts['", ngram, "'] == nil then counts['", ngram, "'] = ", co
unt, " else counts['", ngram, "'] = counts['", ngram, "'] + ", count, " end\n") | 63 io.write("if counts['", ngram, "'] == nil then counts['", ngram, "'] = ", co
unt, " else counts['", ngram, "'] = counts['", ngram, "'] + ", count, " end\n") |
62 end | 64 end |
63 end | 65 end |
OLD | NEW |