<commit_before>#!/usr/bin/env node
const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const os = require('os');
const chalk = require('chalk');
const testCases = require('./cases');

const BLINKSOCKS_PATH = path.resolve(__dirname, '../bin/start.js');
const IPERF_PATH = path.join(__dirname, 'iperf.sh');
const SEC_PER_CASE = 3;

function makeConfs(presets) {
  const serverConf = {
    "service": "tcp://localhost:1082",
    "key": "<KEY>
    "presets": presets,
    // "tls_key": "key.pem",
    // "tls_cert": "cert.pem"
    "log_level": "error"
  };
  const clientConf = {
    "service": "tcp://127.0.0.1:1081",
    // "tls_cert": "cert.pem"
    "dstaddr": {
      "host": "127.0.0.1",
      "port": 1083
    },
    "servers": [Object.assign({}, serverConf, {"enabled": true})],
    "log_level": "error"
  };
  return [clientConf, serverConf];
}

function writeConfs(caseId, presets) {
  const [clientConf, serverConf] = makeConfs(presets);
  const clientJson = path.join(__dirname, `jsons/case-${caseId}-client.json`);
  const serverJson = path.join(__dirname, `jsons/case-${caseId}-server.json`);
  fs.writeFileSync(clientJson, JSON.stringify(clientConf, null, '  '));
  fs.writeFileSync(serverJson, JSON.stringify(serverConf, null, '  '));
  return [clientJson, serverJson];
}

function parseStdout(stdout) {
  const matches = stdout.match(/\[SUM].*sec/g);
  if (matches === null) {
    console.error(stdout);
    return null;
  }
  return matches.slice(-2).map((line) => {
    const [interval, transfer, bitrate] = line.match(/\d+[.\d\-\s]+\w+[\/\w]+/g);<commit_msg>benchmark: use "?forward" instead of "dstaddr"<commit_after>#!/usr/bin/env node
const child_process = require('child_process');
const fs = require('fs');
const path = require('path');
const os = require('os');
const chalk = require('chalk');
const testCases = require('./cases');

const BLINKSOCKS_PATH = path.resolve(__dirname, '../bin/start.js');
const IPERF_PATH = path.join(__dirname, 'iperf.sh');
const SEC_PER_CASE = 3;

function makeConfs(presets) {
  const serverConf = {
    "service": "tcp://localhost:1082",
    "key": "<KEY>
    "presets": presets,
    // "tls_key": "key.pem",
    // "tls_cert": "cert.pem"
    "log_level": "error"
  };
  const clientConf = {
    "service": "tcp://127.0.0.1:1081?forward=127.0.0.1:1083",
    // "tls_cert": "cert.pem"
    "servers": [Object.assign({}, serverConf, {"enabled": true})],
    "log_level": "error"
  };
  return [clientConf, serverConf];
}

function writeConfs(caseId, presets) {
  const [clientConf, serverConf] = makeConfs(presets);
  const clientJson = path.join(__dirname, `jsons/case-${caseId}-client.json`);
  const serverJson = path.join(__dirname, `jsons/case-${caseId}-server.json`);
  fs.writeFileSync(clientJson, JSON.stringify(clientConf, null, '  '));
  fs.writeFileSync(serverJson, JSON.stringify(serverConf, null, '  '));
  return [clientJson, serverJson];
}

function parseStdout(stdout) {
  const matches = stdout.match(/\[SUM].*sec/g);
  if (matches === null) {
    console.error(stdout);
    return null;
  }
  return matches.slice(-2).map((line) => {
    const [interval, transfer, bitrate] = line.match(/\d+[.\d\-\s]+\w+[\/\w]+/g);
{'fraction_non_alphanumeric': 0.20024721878862795, 'fraction_numerical': 0.016069221260815822, 'mean_word_length': 4.146263910969793, 'pattern_counts': {'":': 25, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7449095', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1153, 'n_words': 219}