Last active
November 16, 2015 12:20
-
-
Save danmichaelo/31a4095ee4156298676d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding=utf-8 | |
from __future__ import print_function | |
import requests | |
import time | |
import json | |
from lxml import etree | |
base_url = 'http://bibsys-primo.hosted.exlibrisgroup.com/PrimoWebServices/xservice/search/brief' | |
def make_params(query, sort='popularity'): | |
return { | |
'institution': 'UBO', | |
'indx': '1', | |
'bulkSize': '10', | |
'loc': 'local,scope:(BIBSYS_ILS)', | |
'sortField': sort, | |
'query': query | |
} | |
terms = [ | |
u'Samfunnsvitenskap', | |
u'Pasienter', | |
u'Kunstig liv', | |
u'Kalorimetre', | |
u'C-stjerne', | |
u'Elektriske metoder', | |
u'Tarmbakterier', | |
u'Mutasjoner', | |
u'Naturfilosofi', | |
u'Pulverdiffraksjon', | |
u'Gj\xf8kfamilien', | |
u'\xd8stradioler', | |
u'\xd8kosystemforvaltning', | |
u'Abaloner', | |
u'Fototeknikk', | |
u'Petroleumsindustri', | |
u'Toksisitet', | |
u'Menneskesyn', | |
u'Formelle kommunikasjonsmodeller', | |
u'Funksjonsalgebra', | |
u'Osmium', | |
u'Evolusjon\xe6re algoritmer', | |
u'Sanddyner', | |
u'Bruer', | |
u'Vitenskapelig forfatterskap', | |
u'Merkatorpeilinger', | |
u'Biota', | |
u'Nord-Tr\xf8ndelag', | |
u'Luftfuktighet', | |
u'Funktorer', | |
u'Oljespredning', | |
u'Document style semantics and spesification language', | |
u'Korrelasjonsenergi', | |
u'Signaler', | |
u'Vassfaret', | |
u'Hadamardtransformasjoner', | |
u'Abelske varieteter', | |
u'Spr\xe5kbruk', | |
u'Marine \xf8kosystemer', | |
u'Cellekjerner', | |
u'Karasjok', | |
u'Decipiens', | |
u'Ustabile atomkjerner', | |
u'Alpin vegetasjon', | |
u'Multiple sammenligninger', | |
u'Biologisk krigf\xf8ring', | |
u'Kritisk tenkning', | |
u'Funksjonelle grupper', | |
u'Ekstraterrestrisk intelligent liv', | |
u'Ekstremverditeori', | |
u'Kretsanalyser', | |
u'Klyngeteori', | |
u'Regnskog\xf8kologi', | |
u'Syklisitet', | |
u'Leirskifer', | |
u'Helser\xe5d', | |
u'Rekursiv algebra', | |
u'Monokotyledoner', | |
u'Dibensodioksiner', | |
u'Systemintegrasjon', | |
u'Kjemiske forandringer', | |
u'Matematikkens grunnlag', | |
u'Okkultasjoner', | |
u'Entomologi', | |
u'Busklaver', | |
u'Orologi', | |
u'Teknikk', | |
u'Skivesopper', | |
u'Intranett', | |
u'Vitenskapelig anvendelse', | |
u'Nasjonal it-planlegging', | |
u'Vulkanske prosesser', | |
u'Syntese', | |
u'Dybdem\xe5ling', | |
u'Julia-mengder', | |
u'Politisk overv\xe5king', | |
u'Plastisitet', | |
u'Mikrotektonikk', | |
u'Organografi', | |
u'Devon', | |
u'Europa', | |
u'Statistical package for the social sciences', | |
u'Neotropisk \xf8kologi', | |
u'Vitenskapsmenn', | |
u'Cp-stjerner', | |
u'Intermetalliske faser', | |
u'Modellst\xf8ttet signalbehandling', | |
u'Dynamisk tilordning', | |
u'Str\xe5lingskjemi', | |
u'Viltreservater', | |
u'Sri Lanka', | |
u'Psykobiologi', | |
u'Hubble Space Telescope', | |
u'Kurveapproksimasjon', | |
u'Mosj\xf8en', | |
u'Gravitasjonslinser', | |
u'Syklotroner', | |
u'Fusjonskraftverk', | |
u'Torvmyrer', | |
u'\xc5s'] | |
y_data = [[], []] | |
for n, term in enumerate(terms): | |
q = u'any,contains,{}'.format(term) | |
print(q) | |
formats = ['xml', 'json'] | |
if n % 2: | |
formats = reversed(formats) | |
for f in formats: | |
params = make_params(q) | |
if f == 'json': | |
params['json'] = 'true' | |
start = time.time() | |
response = requests.get(base_url, params=params) | |
end = time.time() | |
if f == 'xml': | |
y_data[0].append(end - start) | |
else: | |
y_data[1].append(end - start) | |
print(u' {}: {} seconds, returned {}'.format(f, end - start, response.status_code)) | |
x_data = ['XML', 'JSON'] | |
data = { | |
'x': x_data, | |
'y': y_data | |
} | |
json.dump(data, open('timing.json','w')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
any,contains,Samfunnsvitenskap | |
xml: 3.80681204796 seconds, returned 200 | |
json: 13.7977728844 seconds, returned 200 | |
any,contains,Pasienter | |
json: 14.1256887913 seconds, returned 200 | |
xml: 8.91854596138 seconds, returned 200 | |
any,contains,Kunstig liv | |
xml: 1.15011787415 seconds, returned 200 | |
json: 2.49607014656 seconds, returned 200 | |
any,contains,Kalorimetre | |
json: 1.32660698891 seconds, returned 200 | |
xml: 0.692940950394 seconds, returned 200 | |
any,contains,C-stjerne | |
xml: 0.239860057831 seconds, returned 200 | |
json: 0.403839826584 seconds, returned 200 | |
any,contains,Elektriske metoder | |
json: 3.46243906021 seconds, returned 200 | |
xml: 1.06274795532 seconds, returned 200 | |
any,contains,Tarmbakterier | |
xml: 1.71620321274 seconds, returned 200 | |
json: 2.58165287971 seconds, returned 200 | |
any,contains,Mutasjoner | |
json: 2.06462788582 seconds, returned 200 | |
xml: 0.816446065903 seconds, returned 200 | |
any,contains,Naturfilosofi | |
xml: 0.821496009827 seconds, returned 200 | |
json: 4.24374699593 seconds, returned 200 | |
any,contains,Pulverdiffraksjon | |
json: 1.19406104088 seconds, returned 200 | |
xml: 0.543021917343 seconds, returned 200 | |
any,contains,Gjøkfamilien | |
xml: 1.1099190712 seconds, returned 200 | |
json: 1.18083286285 seconds, returned 200 | |
any,contains,Østradioler | |
json: 0.535722970963 seconds, returned 200 | |
xml: 0.241748809814 seconds, returned 200 | |
any,contains,Økosystemforvaltning | |
xml: 1.03189086914 seconds, returned 200 | |
json: 2.61867403984 seconds, returned 200 | |
any,contains,Abaloner | |
json: 0.554039001465 seconds, returned 200 | |
xml: 0.310405015945 seconds, returned 200 | |
any,contains,Fototeknikk | |
xml: 1.15796303749 seconds, returned 200 | |
json: 2.94573783875 seconds, returned 200 | |
any,contains,Petroleumsindustri | |
json: 3.95078206062 seconds, returned 200 | |
xml: 1.0648598671 seconds, returned 200 | |
any,contains,Toksisitet | |
xml: 0.39074921608 seconds, returned 200 | |
json: 4.37178897858 seconds, returned 200 | |
any,contains,Menneskesyn | |
json: 12.1503779888 seconds, returned 200 | |
xml: 4.11030888557 seconds, returned 200 | |
any,contains,Formelle kommunikasjonsmodeller | |
xml: 0.544542074203 seconds, returned 200 | |
json: 0.753206014633 seconds, returned 200 | |
any,contains,Funksjonsalgebra | |
json: 0.641382932663 seconds, returned 200 | |
xml: 0.39261007309 seconds, returned 200 | |
any,contains,Osmium | |
xml: 0.332020998001 seconds, returned 200 | |
json: 1.74410891533 seconds, returned 200 | |
any,contains,Evolusjonære algoritmer | |
json: 2.78132987022 seconds, returned 200 | |
xml: 0.641403913498 seconds, returned 200 | |
any,contains,Sanddyner | |
xml: 0.809592008591 seconds, returned 200 | |
json: 1.50541996956 seconds, returned 200 | |
any,contains,Bruer | |
json: 4.42031097412 seconds, returned 200 | |
xml: 1.3776538372 seconds, returned 200 | |
any,contains,Vitenskapelig forfatterskap | |
xml: 3.44828009605 seconds, returned 200 | |
json: 25.039041996 seconds, returned 200 | |
any,contains,Merkatorpeilinger | |
json: 0.517653942108 seconds, returned 200 | |
xml: 0.606947898865 seconds, returned 200 | |
any,contains,Biota | |
xml: 0.443861961365 seconds, returned 200 | |
json: 3.45922684669 seconds, returned 200 | |
any,contains,Nord-Trøndelag | |
json: 10.967911005 seconds, returned 200 | |
xml: 2.06823301315 seconds, returned 200 | |
any,contains,Luftfuktighet | |
xml: 0.417513132095 seconds, returned 200 | |
json: 3.09184408188 seconds, returned 200 | |
any,contains,Funktorer | |
json: 1.53995990753 seconds, returned 200 | |
xml: 0.316751003265 seconds, returned 200 | |
any,contains,Oljespredning | |
xml: 0.514811038971 seconds, returned 200 | |
json: 0.770313024521 seconds, returned 200 | |
any,contains,Document style semantics and spesification language | |
json: 1.72018194199 seconds, returned 200 | |
xml: 1.4155189991 seconds, returned 200 | |
any,contains,Korrelasjonsenergi | |
xml: 0.470496892929 seconds, returned 200 | |
json: 1.13037705421 seconds, returned 200 | |
any,contains,Signaler | |
json: 3.86317801476 seconds, returned 200 | |
xml: 1.43354892731 seconds, returned 200 | |
any,contains,Vassfaret | |
xml: 0.43580698967 seconds, returned 200 | |
json: 2.07367420197 seconds, returned 200 | |
any,contains,Hadamardtransformasjoner | |
json: 0.508819103241 seconds, returned 200 | |
xml: 0.231417894363 seconds, returned 200 | |
any,contains,Abelske varieteter | |
xml: 0.81254696846 seconds, returned 200 | |
json: 3.51663780212 seconds, returned 200 | |
any,contains,Språkbruk | |
json: 7.8950419426 seconds, returned 200 | |
xml: 4.13275003433 seconds, returned 200 | |
any,contains,Marine økosystemer | |
xml: 0.72750210762 seconds, returned 200 | |
json: 4.2505338192 seconds, returned 200 | |
any,contains,Cellekjerner | |
json: 2.40413188934 seconds, returned 200 | |
xml: 0.950975179672 seconds, returned 200 | |
any,contains,Karasjok | |
xml: 1.12226200104 seconds, returned 200 | |
json: 4.24830389023 seconds, returned 200 | |
any,contains,Decipiens | |
json: 2.12345409393 seconds, returned 200 | |
xml: 0.687469005585 seconds, returned 200 | |
any,contains,Ustabile atomkjerner | |
xml: 0.797297000885 seconds, returned 200 | |
json: 0.888221025467 seconds, returned 200 | |
any,contains,Alpin vegetasjon | |
json: 2.43042898178 seconds, returned 200 | |
xml: 0.543015003204 seconds, returned 200 | |
any,contains,Multiple sammenligninger | |
xml: 1.09272003174 seconds, returned 200 | |
json: 1.10359811783 seconds, returned 200 | |
any,contains,Biologisk krigføring | |
json: 2.55149698257 seconds, returned 200 | |
xml: 0.437945842743 seconds, returned 200 | |
any,contains,Kritisk tenkning | |
xml: 1.34057092667 seconds, returned 200 | |
json: 4.64676403999 seconds, returned 200 | |
any,contains,Funksjonelle grupper | |
json: 1.62662196159 seconds, returned 200 | |
xml: 0.815243005753 seconds, returned 200 | |
any,contains,Ekstraterrestrisk intelligent liv | |
xml: 1.73395395279 seconds, returned 200 | |
json: 1.65519189835 seconds, returned 200 | |
any,contains,Ekstremverditeori | |
json: 1.79524612427 seconds, returned 200 | |
xml: 0.549288034439 seconds, returned 200 | |
any,contains,Kretsanalyser | |
xml: 0.406183004379 seconds, returned 200 | |
json: 1.57781195641 seconds, returned 200 | |
any,contains,Klyngeteori | |
json: 2.19332003593 seconds, returned 200 | |
xml: 0.272440910339 seconds, returned 200 | |
any,contains,Regnskogøkologi | |
xml: 0.804347038269 seconds, returned 200 | |
json: 1.97421693802 seconds, returned 200 | |
any,contains,Syklisitet | |
json: 1.41705989838 seconds, returned 200 | |
xml: 0.616024017334 seconds, returned 200 | |
any,contains,Leirskifer | |
xml: 1.0529999733 seconds, returned 200 | |
json: 1.6053571701 seconds, returned 200 | |
any,contains,Helseråd | |
json: 2.17464613914 seconds, returned 200 | |
xml: 0.391049861908 seconds, returned 200 | |
any,contains,Rekursiv algebra | |
xml: 0.428339958191 seconds, returned 200 | |
json: 1.09229803085 seconds, returned 200 | |
any,contains,Monokotyledoner | |
json: 1.43258690834 seconds, returned 200 | |
xml: 0.748799800873 seconds, returned 200 | |
any,contains,Dibensodioksiner | |
xml: 0.55613899231 seconds, returned 200 | |
json: 0.377465009689 seconds, returned 200 | |
any,contains,Systemintegrasjon | |
json: 3.37688994408 seconds, returned 200 | |
xml: 0.504362821579 seconds, returned 200 | |
any,contains,Kjemiske forandringer | |
xml: 1.0680410862 seconds, returned 200 | |
json: 1.30912399292 seconds, returned 200 | |
any,contains,Matematikkens grunnlag | |
json: 2.17432808876 seconds, returned 200 | |
xml: 1.15310001373 seconds, returned 200 | |
any,contains,Okkultasjoner | |
xml: 0.266983032227 seconds, returned 200 | |
json: 0.751060009003 seconds, returned 200 | |
any,contains,Entomologi | |
json: 5.31273508072 seconds, returned 200 | |
xml: 0.374102830887 seconds, returned 200 | |
any,contains,Busklaver | |
xml: 0.544844150543 seconds, returned 200 | |
json: 1.49058198929 seconds, returned 200 | |
any,contains,Orologi | |
json: 0.703965902328 seconds, returned 200 | |
xml: 0.468600988388 seconds, returned 200 | |
any,contains,Teknikk | |
xml: 5.3497030735 seconds, returned 200 | |
json: 7.42026090622 seconds, returned 200 | |
any,contains,Skivesopper | |
json: 5.48322892189 seconds, returned 200 | |
xml: 0.591283082962 seconds, returned 200 | |
any,contains,Intranett | |
xml: 1.14167690277 seconds, returned 200 | |
json: 7.63537693024 seconds, returned 200 | |
any,contains,Vitenskapelig anvendelse | |
json: 2.1668741703 seconds, returned 200 | |
xml: 1.03864407539 seconds, returned 200 | |
any,contains,Nasjonal it-planlegging | |
xml: 0.456534862518 seconds, returned 200 | |
json: 1.39668512344 seconds, returned 200 | |
any,contains,Vulkanske prosesser | |
json: 1.1971988678 seconds, returned 200 | |
xml: 0.378430128098 seconds, returned 200 | |
any,contains,Syntese | |
xml: 1.03857278824 seconds, returned 200 | |
json: 4.4561150074 seconds, returned 200 | |
any,contains,Dybdemåling | |
json: 1.73509120941 seconds, returned 200 | |
xml: 0.705371856689 seconds, returned 200 | |
any,contains,Julia-mengder | |
xml: 0.938601016998 seconds, returned 200 | |
json: 0.700227022171 seconds, returned 200 | |
any,contains,Politisk overvåking | |
json: 3.89005494118 seconds, returned 200 | |
xml: 0.717707872391 seconds, returned 200 | |
any,contains,Plastisitet | |
xml: 0.787271976471 seconds, returned 200 | |
json: 8.82634592056 seconds, returned 200 | |
any,contains,Mikrotektonikk | |
json: 0.623543024063 seconds, returned 200 | |
xml: 0.927186965942 seconds, returned 200 | |
any,contains,Organografi | |
xml: 0.530117034912 seconds, returned 200 | |
json: 1.53172707558 seconds, returned 200 | |
any,contains,Devon | |
json: 9.48434686661 seconds, returned 200 | |
xml: 0.445719003677 seconds, returned 200 | |
any,contains,Europa | |
xml: 1.22087192535 seconds, returned 200 | |
json: 4.82639193535 seconds, returned 200 | |
any,contains,Statistical package for the social sciences | |
json: 10.4371659756 seconds, returned 200 | |
xml: 2.95401501656 seconds, returned 200 | |
any,contains,Neotropisk økologi | |
xml: 1.80883383751 seconds, returned 200 | |
json: 1.20178413391 seconds, returned 200 | |
any,contains,Vitenskapsmenn | |
json: 4.99759697914 seconds, returned 200 | |
xml: 4.25197410583 seconds, returned 200 | |
any,contains,Cp-stjerner | |
xml: 0.901543140411 seconds, returned 200 | |
json: 0.397619009018 seconds, returned 200 | |
any,contains,Intermetalliske faser | |
json: 9.68935394287 seconds, returned 200 | |
xml: 3.20645189285 seconds, returned 200 | |
any,contains,Modellstøttet signalbehandling | |
xml: 0.312540054321 seconds, returned 200 | |
json: 0.756596088409 seconds, returned 200 | |
any,contains,Dynamisk tilordning | |
json: 0.673141002655 seconds, returned 200 | |
xml: 0.657291889191 seconds, returned 200 | |
any,contains,Strålingskjemi | |
xml: 1.58623886108 seconds, returned 200 | |
json: 1.63779401779 seconds, returned 200 | |
any,contains,Viltreservater | |
json: 1.01551508904 seconds, returned 200 | |
xml: 1.7493519783 seconds, returned 200 | |
any,contains,Sri Lanka | |
xml: 2.1242890358 seconds, returned 200 | |
json: 4.9053709507 seconds, returned 200 | |
any,contains,Psykobiologi | |
json: 6.33669996262 seconds, returned 200 | |
xml: 0.519999980927 seconds, returned 200 | |
any,contains,Hubble Space Telescope | |
xml: 0.76185297966 seconds, returned 200 | |
json: 2.64037179947 seconds, returned 200 | |
any,contains,Kurveapproksimasjon | |
json: 1.38911294937 seconds, returned 200 | |
xml: 2.32840585709 seconds, returned 200 | |
any,contains,Mosjøen | |
xml: 1.04284620285 seconds, returned 200 | |
json: 2.89450502396 seconds, returned 200 | |
any,contains,Gravitasjonslinser | |
json: 2.8830640316 seconds, returned 200 | |
xml: 4.06696009636 seconds, returned 200 | |
any,contains,Syklotroner | |
xml: 4.82617712021 seconds, returned 200 | |
json: 9.41208791733 seconds, returned 200 | |
any,contains,Fusjonskraftverk | |
json: 0.695036172867 seconds, returned 200 | |
xml: 0.320658922195 seconds, returned 200 | |
any,contains,Torvmyrer | |
xml: 3.35235714912 seconds, returned 200 | |
json: 2.31130003929 seconds, returned 200 | |
any,contains,Ås | |
json: 24.4423480034 seconds, returned 200 | |
xml: 6.33681106567 seconds, returned 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment