Ejemplo n.º 1
0
# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP. The resulting page is written to a file.
#
# More complex HTTP scripts are best created with the TCPProxy.

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest

import data_urls
import jarray
import random

test1 = Test(1, "Request random dataset")
req = HTTPRequest()
req.setReadResponseBody(False)
chunk = 1024 * 512

properties = grinder.properties.getPropertySubset('dapbench.')

dataset_list = properties['datasets']


def streamed_get(url):
    buf = jarray.zeros(chunk, 'b')
    total = 0
    resp = req.GET(url)
    stream = resp.getInputStream()
    ret = 0
    while ret != -1:
        ret = stream.read(buf)
Ejemplo n.º 2
0
# A simple example using the HTTP plugin that shows the retrieval of a
# single page via HTTP. The resulting page is written to a file.
#
# More complex HTTP scripts are best created with the TCPProxy.

from net.grinder.script.Grinder import grinder
from net.grinder.script import Test
from net.grinder.plugin.http import HTTPRequest

import data_urls
import jarray
import random

test1 = Test(1, "Request random dataset")
req = HTTPRequest()
req.setReadResponseBody(False)
chunk = 1024*512

properties = grinder.properties.getPropertySubset('dapbench.')

dataset_list = properties['datasets']

def streamed_get(url):
    buf = jarray.zeros(chunk, 'b')
    total = 0
    resp = req.GET(url)
    stream = resp.getInputStream()
    ret = 0
    while ret != -1:
        ret = stream.read(buf)
        total += ret