array join vs string connect

JavaScript performance comparison

Revision 67 of this test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
array join
var match_state = '1,3,4,';
var match_state_weather = ' 2,3,4,-1,';
var match_state_bifen = '0,-14,';
var table_str = [];
var rangqiu = '';

for (var list in matchList) {
  match = matchList[list];
  match_id = match['MatchID'];

  //--tr start
  table_str[table_str.length] = "<tr is_ding = '2' num = " + list + " class=''  match_id='" + match_id + "' id='" + match_id + "_tr' >";
  //--序号
  table_str[table_str.length] = '<td role="序号"><label><input  type="checkbox" name="match_tr_checkbox" onclick="hideTr(' + match_id + ')" checked="checked">&nbsp;' + match['number'] + '</label><input type="hidden" value=' + parseInt(match['number'], 10) + ' name="sort_input" ></td>';

  //--leaguename
  table_str[table_str.length] = '<td style="color:#fff;" role="competition" bgcolor="' + match['Color'] + '">' + match['LeagueName'] + '<input type="hidden" name="league_id_h"  value="' + match['LeagueID'] + '"><input type="hidden" league_id="' + match['LeagueID'] + '" name="sort_input" ></td>';

  //--分组
  table_str[table_str.length] = '<td role="分组"><div class="shortenTitle">';
  if (match['GroupName'] == '默认分组' || match['GroupName'] == '联赛') {
    table_str[table_str.length] = '第' + match['TurnID'] + '轮';
  } else {
    table_str[table_str.length] = match['GroupName'];
  }
  table_str[table_str.length] = '</div></td>';

  //--时间
  table_str[table_str.length] = '<td role="比赛时间">' + match['showTime'] + '<input type="hidden" name="' + match_id + '_ji_time_h"  value="' + match['StartTimeH'] + '"></td>';

  //--事件/时间
  table_str[table_str.length] = '<td is_over=' + match['MatchState'];
  if (onmatch_str.indexOf(match['MatchState'] + ',') != -1) {
    table_str[table_str.length] = ' class="under_way" ';
  }
  table_str[table_str.length] = ' >';
  if (match_state.indexOf(match['MatchState'] + ',') == -1) {
    table_str[table_str.length] = match['MatchStateName'];
  } else {
    table_str[table_str.length] = match['TimeEvent'] + '′';
  }
  table_str[table_str.length] = '</td>';

  //--主队名称
  table_str[table_str.length] = '<td role="主队" class="home">';

  if (match.HomeRC > 0) {
    table_str[table_str.length] = '<i class="warning">' + match['HomeRC'] + '</i>';
  }
  table_str[table_str.length] = '<sup name="_home_sup_rank">[' + match['HomeRank'] + ']</sup><label name="home_j" >' + match['HomeName'] + '</label><label style="display:none;" name="home_f">' + match['HomeNameF'] + '</label>';
  table_str[table_str.length] = '<input type="hidden" value="' + match['HomeRC'] + '" id="' + match_id + '_home_ry">';
  if (match['Ranqiu'] != '0') {
    class_rangqiu = 'concede';
    if (match['Rangqiu'] == '+1') {
      class_rangqiu = 'plus_concede';
    }
    table_str[table_str.length] = '<i  name="rangqiu_i_h" style="display:none" class="' + class_rangqiu + '">(' + match['Rangqiu'] + ')</i>';
  }
  table_str[table_str.length] = '</td>';

  //--比分
  table_str[table_str.length] = '<td  role="比分"><div class="showscore_area">';
  table_str[table_str.length] = '<a href="#1" class="showscore" ';
  if (onmatch_color_str.indexOf(match['MatchState'] + ',') != -1) {
    table_str[table_str.length] = ' style="color:blue;" ';
  }
  table_str[table_str.length] = '><h3>';

  if (match_state_bifen.indexOf(match['MatchState'] + ',') != -1) {
    match['HomeGoals'] = '';
    match['AwayGoals'] = '';
  }
  table_str[table_str.length] = '<label id="' + match_id + '_home_goals" >' + match['HomeGoals'] + '</label>-<label id="' + match_id + '_away_goals" >' + match['AwayGoals'] + '</label>';

  table_str[table_str.length] = '</h3></a>';

  //--下拉
  table_str[table_str.length] = '<div class="match_log" style="display:none;"><table  cellpadding="0" cellspacing="0" width="100%"><colgroup><col width="30%" /><col width="10%" /><col width="30%" /></colgroup><tbody id="' + match_id + '_event_new" ></tbody><tfoot><tr><td  colspan="3" ><table  cellpadding="0" cellspacing="0" width="100%"  ><colgroup> <col width="20%" /> <col width="60%" /> <col width="20%" /> </colgroup><tbody id="' + match_id + '_state_new" ></tbody></table></td></tr></tfoot></table></div></div></td>';

  //--客队信息             
  table_str[table_str.length] = '<td role="客队" class="visitor">';
  table_str[table_str.length] = '<label name="away_f" style="display:none;">' + match['AwayNameF'] + '</label><label name="away_j">' + match['AwayName'] + '</label><sup name="_away_sup_rank" >[' + match['AwayRank'] + ']</sup>';
  table_str[table_str.length] = '<input type="hidden" value="' + match['AwayRC'] + '" id="' + match_id + '_away_ry">'
  if (parseInt(match['AwayRC'], 10) > 0) {
    table_str[table_str.length] = '<i class="warning">' + match['AwayRC'] + '</i>';
  }
  table_str[table_str.length] = '</td>';

  //--竞赔
  table_str[table_str.length] = '<td role="win" class="sp_noborder spcon"><span ></span></td>';
  table_str[table_str.length] = '<td role="DrawnOdds" class="sp_noborder spcon"><span></span></td>';
  table_str[table_str.length] = '<td role="Lost" class="spcon"><span></span></td>';

  //--半场比分/天气
  table_str[table_str.length] = '<td class="weather_or_halfscore" id="' + match_id + '_half_td" >';
  if (match_state_weather.indexOf(match['MatchState'] + ',') == -1) {
    if (match['Weather'].length > 0) {
      table_str[table_str.length] = '<i class="' + match['weatherClass'] + '" title="' + match['Weather'] + '"></i>';
    }
  } else {
    table_str[table_str.length] = '<em style="color:#666"  id="' + match_id + '_half_home_goals" >' + match['HalfHomeGoals'] + '-</em><em style="color:#666"  id="' + match_id + '_half_away_goals" >' + match['HalfAwayGoals'] + '</em>';
  }
  table_str[table_str.length] = '</td>';

  //--欧/析
  table_str[table_str.length] = '<td role="数据"><a target="_Blank" href="http://' + ip_210 + '/Match/EuropeLast.php?MatchID=' + match_id + '">欧</a>/<a target="_Blank" href="http://' + ip_210 + '/Match/LastMatch.php?MatchID=' + match_id + '">析</a></td>';

  //--直播
  zhibo_str = '';
  if (match['SwfUrl'] != null) {
    zhibo_class = 'live';
    if (match['SwfType'] == 2) {
      zhibo_class += ' highlight';
    }
    zhibo_str = '<a href="' + match['SwfUrl'] + '" target="_Blank" title="直播" class="' + zhibo_class + '">直播</a>';
  }
  table_str[table_str.length] = '<td role="直播">' + zhibo_str + '</td>';
  //--置顶
  table_str[table_str.length] = '<td role="置顶"><a href="javascript:void(0)" onclick="getAccessNotice(' + match_id + ');zhiding(' + match_id + ',' + list + ');" title="置顶" class="stick"></a></td>';

}

var output = table_str.join('');
pending…
string connect
var match_state = '1,3,4,';
var match_state_weather = ' 2,3,4,-1,';
var match_state_bifen = '0,-14,';
var table_str = ' ';
var rangqiu = '';

for (var list in matchList) {
  match = matchList[list];
  match_id = match['MatchID'];

  //--tr start
  table_str += "<tr is_ding = '2' num = " + list + " class=''  match_id='" + match_id + "' id='" + match_id + "_tr' >";
  //--序号
  table_str += '<td role="序号"><label><input  type="checkbox" name="match_tr_checkbox" onclick="hideTr(' + match_id + ')" checked="checked">&nbsp;' + match['number'] + '</label><input type="hidden" value=' + parseInt(match['number'], 10) + ' name="sort_input" ></td>';

  //--leaguename
  table_str += '<td style="color:#fff;" role="competition" bgcolor="' + match['Color'] + '">' + match['LeagueName'] + '<input type="hidden" name="league_id_h"  value="' + match['LeagueID'] + '"><input type="hidden" league_id="' + match['LeagueID'] + '" name="sort_input" ></td>';

  //--分组
  table_str += '<td role="分组"><div class="shortenTitle">';
  if (match['GroupName'] == '默认分组' || match['GroupName'] == '联赛') {
    table_str += '第' + match['TurnID'] + '轮';
  } else {
    table_str += match['GroupName'];
  }
  table_str += '</div></td>';

  //--时间
  table_str += '<td role="比赛时间">' + match['showTime'] + '<input type="hidden" name="' + match_id + '_ji_time_h"  value="' + match['StartTimeH'] + '"></td>';

  //--事件/时间
  table_str += '<td is_over=' + match['MatchState'];
  if (onmatch_str.indexOf(match['MatchState'] + ',') != -1) {
    table_str += ' class="under_way" ';
  }
  table_str += ' >';
  if (match_state.indexOf(match['MatchState'] + ',') == -1) {
    table_str += match['MatchStateName'];
  } else {
    table_str += match['TimeEvent'] + '′';
  }
  table_str += '</td>';

  //--主队名称
  table_str += '<td role="主队" class="home">';

  if (match.HomeRC > 0) {
    table_str += '<i class="warning">' + match['HomeRC'] + '</i>';
  }
  table_str += '<sup name="_home_sup_rank">[' + match['HomeRank'] + ']</sup><label name="home_j" >' + match['HomeName'] + '</label><label style="display:none;" name="home_f">' + match['HomeNameF'] + '</label>';
  table_str += '<input type="hidden" value="' + match['HomeRC'] + '" id="' + match_id + '_home_ry">';
  if (match['Ranqiu'] != '0') {
    class_rangqiu = 'concede';
    if (match['Rangqiu'] == '+1') {
      class_rangqiu = 'plus_concede';
    }
    table_str += '<i  name="rangqiu_i_h" style="display:none" class="' + class_rangqiu + '">(' + match['Rangqiu'] + ')</i>';
  }
  table_str += '</td>';

  //--比分
  table_str += '<td  role="比分"><div class="showscore_area">';
  table_str += '<a href="#1" class="showscore" ';
  if (onmatch_color_str.indexOf(match['MatchState'] + ',') != -1) {
    table_str += ' style="color:blue;" ';
  }
  table_str += '><h3>';

  if (match_state_bifen.indexOf(match['MatchState'] + ',') != -1) {
    match['HomeGoals'] = '';
    match['AwayGoals'] = '';
  }
  table_str += '<label id="' + match_id + '_home_goals" >' + match['HomeGoals'] + '</label>-<label id="' + match_id + '_away_goals" >' + match['AwayGoals'] + '</label>';

  table_str += '</h3></a>';

  //--下拉
  table_str += '<div class="match_log" style="display:none;"><table  cellpadding="0" cellspacing="0" width="100%"><colgroup><col width="30%" /><col width="10%" /><col width="30%" /></colgroup><tbody id="' + match_id + '_event_new" ></tbody><tfoot><tr><td  colspan="3" ><table  cellpadding="0" cellspacing="0" width="100%"  ><colgroup> <col width="20%" /> <col width="60%" /> <col width="20%" /> </colgroup><tbody id="' + match_id + '_state_new" ></tbody></table></td></tr></tfoot></table></div></div></td>';

  //--客队信息             
  table_str += '<td role="客队" class="visitor">';
  table_str += '<label name="away_f" style="display:none;">' + match['AwayNameF'] + '</label><label name="away_j">' + match['AwayName'] + '</label><sup name="_away_sup_rank" >[' + match['AwayRank'] + ']</sup>';
  table_str += '<input type="hidden" value="' + match['AwayRC'] + '" id="' + match_id + '_away_ry">'
  if (parseInt(match['AwayRC'], 10) > 0) {
    table_str += '<i class="warning">' + match['AwayRC'] + '</i>';
  }
  table_str += '</td>';

  //--竞赔
  table_str += '<td role="win" class="sp_noborder spcon"><span ></span></td>';
  table_str += '<td role="DrawnOdds" class="sp_noborder spcon"><span></span></td>';
  table_str += '<td role="Lost" class="spcon"><span></span></td>';

  //--半场比分/天气
  table_str += '<td class="weather_or_halfscore" id="' + match_id + '_half_td" >';
  if (match_state_weather.indexOf(match['MatchState'] + ',') == -1) {
    if (match['Weather'].length > 0) {
      table_str += '<i class="' + match['weatherClass'] + '" title="' + match['Weather'] + '"></i>';
    }
  } else {
    table_str += '<em style="color:#666"  id="' + match_id + '_half_home_goals" >' + match['HalfHomeGoals'] + '-</em><em style="color:#666"  id="' + match_id + '_half_away_goals" >' + match['HalfAwayGoals'] + '</em>';
  }
  table_str += '</td>';

  //--欧/析
  table_str += '<td role="数据"><a target="_Blank" href="http://' + ip_210 + '/Match/EuropeLast.php?MatchID=' + match_id + '">欧</a>/<a target="_Blank" href="http://' + ip_210 + '/Match/LastMatch.php?MatchID=' + match_id + '">析</a></td>';

  //--直播
  zhibo_str = '';
  if (match['SwfUrl'] != null) {
    zhibo_class = 'live';
    if (match['SwfType'] == 2) {
      zhibo_class += ' highlight';
    }
    zhibo_str = '<a href="' + match['SwfUrl'] + '" target="_Blank" title="直播" class="' + zhibo_class + '">直播</a>';
  }
  table_str += '<td role="直播">' + zhibo_str + '</td>';
  //--置顶
  table_str += '<td role="置顶"><a href="javascript:void(0)" onclick="getAccessNotice(' + match_id + ');zhiding(' + match_id + ',' + list + ');" title="置顶" class="stick"></a></td>';

}
//      return table_str;
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment