{% if comparison %}
<table class='test-results'>
  <thead>
    <tr>
      <td rowspan='2'></td>
      {% for build, environments in comparison.environments.items() %}
      <th colspan={{environments|length}}>
        <a href="{{project_url(build)}}">
          {% if project %}
            {{ _('build %s') % build.version }}
          {% else %}
            {{ _('%s, build %s') % (build.project, build.version) }}
          {% endif %}
        </a>
      </th>
      {% endfor %}
    </tr>
    <tr>
      {% for build, environments in comparison.environments.items() %}
        {% for environment in environments %}
        <th>
          {{environment}}
          <br />
          {{ _('mean (stdev)') }}
        </th>
        {% endfor %}
      {% endfor %}
    </tr>
  </thead>
  {% for test, results in comparison.results %}
    <tr>
      <th>{{test}}</th>
      {% for build, environments in comparison.environments.items() %}
        {% for environment in environments %}
          {% with result=results.get((build, environment)) %}
            {% if result %}
              {% if comparison_type == 'test' %}
                <td class='{{result|slugify}}'>
                  <a href="{{url('test_history', args=[build.project.group.slug, build.project.slug, test])}}">
                    <strong>{{result}}</strong>
                  </a>
                </td>
              {% else %}
                {% set mean = result.0|float %}
                {% set stddev = result.1|float %}
                {% set total = result.2|int %}
                <td title="{{_('Number of measurements: %d' % total)}}">
                  <strong>{{'%.2f' % mean}} ({{'%.2f' % stddev}})</strong>
                </td>
              {% endif %}
            {% else %}
              <td><i>{{ _('n/a') }}</i></td>
            {% endif %}
          {% endwith %}
        {% endfor %}
      {% endfor %}
    </tr>
  {% endfor %}
</table>
{% endif %}
