 request(remoteSchema, (error, response, body) ->
   zValidator.setRemoteReference(remoteSchema, JSON.parse(actualDraft)))
 
-amanda = require "amanda"
+JSCK = (draft) ->
+  switch draft
+    when 3 then require "../src/draft3"
+    when 4 then require "../src/draft4"
 
-samples = 64
 
+
+# do the actual benchmarking
 module.exports =
 
   benchmark: ({draft, name, schema, valid_doc, repeats}) ->
+
+    libraries = []
 
     console.log """
 

# stdlib
util = require "util"

# ours
Benchmark = require "./benchmark.coffee"

# Validators
JSCK = (draft) ->
  switch draft
    when 3 then require "../src/draft3"
    when 4 then require "../src/draft4"
  
JSONSchema= require('jsonschema').Validator
JSV = require("JSV").JSV
JaySchema = require("jayschema")
tv4 = require("tv4").tv4
jsonGateCreateSchema = require("json-gate").createSchema

# z-schema setup's pretty involved
z = require("z-schema")
request = require("request")



    """

    # these validators work for either draft 3 or 4 of JSON Schema
    jsck = new Benchmark "JSCK: valid document", (bm) ->
      bm.setup -> new (JSCK draft)(schema)
      bm.measure (validator) ->
        for i in [1..repeats]
          result = validator.validate(valid_doc)
    libraries.push jsck

    jsonschema = new Benchmark "jsonschema: valid document", (bm) ->
      bm.setup -> new JSONSchema()
      bm.measure (validator) ->
        for i in [1..repeats]
          result = validator.validate(valid_doc, schema).errors
    libraries.push jsonschema

    tv4Benchmark = new Benchmark "tv4: valid document", (bm) ->
      bm.setup -> tv4
      bm.measure (validator) ->
        for i in [1..repeats]
          result = validator.validate(valid_doc, schema).error
    libraries.push tv4Benchmark

    switch draft
      when 4 # these validators work only for draft 4 of JSON Schema

        jayschema = new Benchmark "jayschema: valid document", (bm) ->
          bm.setup -> new JaySchema()
          bm.measure (validator) ->
            for i in [1..repeats]
              result = validator.validate(valid_doc, schema)
        libraries.push jayschema

        # note: z-schema will not recognize the valid doc as a valid doc
        zSchema = new Benchmark "z-schema: valid document", (bm) ->
          bm.setup -> zValidator
          bm.measure (validator) ->
            for i in [1..repeats]
              result = validator.validate(valid_doc, schema)
        libraries.push zSchema

    # these validators work only for draft 3 of JSON Schema
      when 3

        # note: amanda reports errors on integers as utc-millisec,
        # and on http://localhost:8998, due to a huge URL regex
        amanda_bm = new Benchmark "Amanda: valid document", (bm) ->
          bm.setup ->
            amandaValidator = amanda("json")
          bm.measure (validator) ->
            for i in [1..repeats]
              # pass Amanda an empty error-reporting function
              result = validator.validate(valid_doc, schema, () ->)
        libraries.push amanda_bm

        jsv_bm = new Benchmark "JSV: valid document", (bm) ->
          bm.setup ->
            jsv = JSV.createEnvironment("json-schema-draft-03")
            jsv.createSchema(schema)
          bm.measure (validator) ->
            for i in [1..repeats]
              result = validator.validate(valid_doc).errors
        libraries.push jsv_bm

        jsonGate_bm = new Benchmark "json-gate: valid document", (bm) ->
          bm.setup ->
            jg = jsonGateCreateSchema(schema)
          bm.measure (validator) ->
            for i in [1..repeats]
              result = validator.validate(valid_doc)
        libraries.push jsonGate_bm

    results = Benchmark.compare libraries, {samples}

