void doPerf(String writerName, SolrQueryRequest req, int encIter, int decIter) throws Exception {
    SolrQueryResponse rsp = getResponse(req);
    QueryResponseWriter w = h.getCore().getQueryResponseWriter(writerName);

    ByteArrayOutputStream out = null;

    System.gc();
    long start = System.currentTimeMillis();
    for (int i = 0; i < encIter; i++) {
      if (w instanceof BinaryQueryResponseWriter) {
        BinaryQueryResponseWriter binWriter = (BinaryQueryResponseWriter) w;
        out = new ByteArrayOutputStream();
        binWriter.write(out, req, rsp);
        out.close();
      } else {
        out = new ByteArrayOutputStream();
        // to be fair, from my previous tests, much of the performance will be sucked up
        // by java's UTF-8 encoding/decoding, not the actual writing
        Writer writer = new OutputStreamWriter(out, "UTF-8");
        w.write(writer, req, rsp);
        writer.close();
      }
    }

    long encodeTime = Math.max(System.currentTimeMillis() - start, 1);

    byte[] arr = out.toByteArray();

    start = System.currentTimeMillis();
    writerName = writerName.intern();
    for (int i = 0; i < decIter; i++) {
      ResponseParser rp = null;
      if (writerName == "xml") {
        rp = new XMLResponseParser();
      } else if (writerName == "javabin") {
        rp = new BinaryResponseParser();
      } else {
        break;
      }
      ByteArrayInputStream in = new ByteArrayInputStream(arr);
      rp.processResponse(in, "UTF-8");
    }

    long decodeTime = Math.max(System.currentTimeMillis() - start, 1);

    log.info(
        "writer "
            + writerName
            + ", size="
            + out.size()
            + ", encodeRate="
            + (encodeTime == 1 ? "N/A" : "" + (encIter * 1000L / encodeTime))
            + ", decodeRate="
            + (decodeTime == 1 ? "N/A" : "" + (decIter * 1000L / decodeTime)));

    req.close();
    SolrRequestInfo.clearRequestInfo();
  }
  /** make sure to close req after you are done using the response */
  public SolrQueryResponse getResponse(SolrQueryRequest req) throws Exception {
    SolrQueryResponse rsp = new SolrQueryResponse();
    SolrRequestInfo.setRequestInfo(new SolrRequestInfo(req, rsp));

    h.getCore().execute(h.getCore().getRequestHandler(null), req, rsp);
    if (rsp.getException() != null) {
      throw rsp.getException();
    }
    return rsp;
  }