Ronny Pfannschmidt avatar Ronny Pfannschmidt committed fcd4aa1

analysis composeapp

Comments (0)

Files changed (5)

 .*\.html
+.couchdb-compose-external-cache

composeapp/couchdb-compose.yml

+doc:
+  _id: _design/evolve-analyze
+
+
+
+load:
+- views/taskinfo.yml
+- lists.yml
+- lib/tabular.coffee
+
+externals:
+- name: underscore
+  url: http://underscorejs.org/underscore.js
+

composeapp/lib/tabular.coffee

+class TableWriter
+  constructor: (@send_one, @items, @discriminate) ->
+    @buffers = new Array(@items.length)
+    for i in [1..@items.length]
+      @buffers[i] = new Array()
+
+  make_header: (maker) ->
+    @header_maker = maker
+    maker @send_one, @items[0]
+
+  make_rows: (getRow, maker) ->
+    while row = getRow()
+      maker @send_one, row
+
+  finalize: () ->
+    for buffer in @buffers
+      buffer.forEach @send_one
+
+exports.TableWriter = TableWriter

composeapp/lists.yml

+tabular.coffee: |
+  (head, req) ->
+    {_} = require 'underscore'
+    {TableWriter} = require 'lib/tabular'
+    start headers: {'Content-Type': 'text/html'}
+
+    send '<h1>tabular</h1>'
+    send '<style> .correct {background-color: green;} .incorrect {background-color: red;}</style>'
+    info = _.clone req.query
+    delete info.group
+    baseinfo = getRow().value
+    hw_array = baseinfo.axis["height-weight"]
+    hw = hw_array[0]
+    tw = new TableWriter send, hw_array, (row) -> row.value.spec['height-weight']
+
+    tw.make_header (send, val) ->
+      send '<h2>heights weight' + val + '</h2>'
+      send '<table>\n'
+      send '  <tr>\n    <th>*\n'
+      for p in baseinfo.axis.population
+        send '    <th>' + p + '\n'
+    last = {}
+    tw.make_rows getRow, (send, row) ->
+      val = row.value
+      if val.spec['height-weight'] != hw
+        return
+      if last.generations != val.spec.generations
+        send '  <tr><th>' + val.spec.generations + '\n'
+      if val.correct
+        send '    <td class=correct>'
+      else
+        send '    <td class=incorrect>'
+      send '&nbsp\n'
+      last = val.spec || {}
+    return

composeapp/views/taskinfo.yml

+map.coffee: |
+  (doc) ->
+    if doc.type == 'juggler:order'
+      emit [doc._id], doc
+    if doc.type == 'juggler:task'
+      emit doc._id.split('.'), doc.spec
+    if doc.line
+      line = doc.line
+
+      if line.indexOf("Total") != -1
+        seconds = new Number(line.match(/\d+\.\d+/)[0])
+        emit doc.task.split('.'), time: seconds
+      else if line.indexOf("Gen.") != -1
+        re = /Gen\. (\d+) \((\d+.\d+)%\)/
+        info = line.match(re)
+        gen = new Number(info[1])
+        percent = new Number(info[2])
+
+        parts = line.match(/(\d+.\d+)\((\d+.\d+)\)/g)
+        parse_info = (item) ->
+            match = item.match(/(\d+.\d+)\((\d+.\d+)\)/)
+            return norm: new Number(match[1]), raw: new Number(match[2])
+        infos =
+          max: parse_info(parts[0])
+          min: parse_info(parts[1])
+          avg: parse_info(parts[2])
+
+        emit doc.task.split('.'), {gen: gen, percent: percent, infos: infos}
+      else
+        correct = /sqrt\(add\(mul\((\w), \1\), mul\(((?!\1)\w), \2\)\)\)/
+        emit doc.task.split('.'), result: line, correct: correct.test(line)
+    return
+
+reduce.coffee: |
+  (keys, values, rereduce) ->
+
+    data = {}
+    for value in values
+        if 'population' of value
+          data.spec = value
+        if 'spec' of value
+          data.spec = value.spec
+        if 'axis' of value
+          data.axis = value.axis
+        if 'result' of value
+          data.result = value.result
+          data.correct = value.correct
+        if 'gen' of value and 'gen' not of data and value.infos?.min?.raw? == 0
+          # null check
+          data.gen = value.gen
+
+    return data
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.