Last active
August 29, 2015 14:21
-
-
Save ericdill/ca047302c2c1f1865415 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| { | |
| "cells": [ | |
| { | |
| "metadata": { | |
| "collapsed": true, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "from metadatastore.api import *\nfrom metadatastore.odm_templates import *\nimport mongoengine\nfrom datetime import datetime\nimport time\nimport numpy as np\nfrom pprint import pprint\nfrom metadatastore.examples.sample_data.temperature_ramp import run\nimport time as ttime", | |
| "execution_count": 1, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": false, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "# seed the database with a ton of documents\nstart = ttime.time()\nfor _ in xrange(1000):\n if _ % 25 == 0:\n print('{}. {}s since start'.format(_, round(ttime.time()-start)))\n run()", | |
| "execution_count": 2, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": "0. 0.0s since start\n25. 4.0s since start\n50. 7.0s since start\n75. 11.0s since start\n100. 14.0s since start\n125. 18.0s since start\n150. 21.0s since start\n175. 25.0s since start\n200. 28.0s since start\n225. 32.0s since start\n250. 35.0s since start\n275. 39.0s since start\n300. 42.0s since start\n325. 46.0s since start\n350. 49.0s since start\n375. 53.0s since start\n400. 56.0s since start\n425. 60.0s since start\n450. 64.0s since start\n475. 67.0s since start\n500. 71.0s since start\n525. 75.0s since start\n550. 78.0s since start\n575. 82.0s since start\n600. 86.0s since start\n625. 90.0s since start\n650. 93.0s since start\n675. 97.0s since start\n700. 100.0s since start\n725. 104.0s since start\n750. 107.0s since start\n775. 111.0s since start\n800. 114.0s since start\n825. 118.0s since start\n850. 121.0s since start\n875. 125.0s since start\n900. 128.0s since start\n925. 132.0s since start\n950. 135.0s since start\n975. 139.0s since start\n", | |
| "name": "stdout" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": true, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "rs, = find_last()", | |
| "execution_count": 3, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "trusted": true, | |
| "collapsed": false | |
| }, | |
| "cell_type": "code", | |
| "source": "rs.uid", | |
| "execution_count": 4, | |
| "outputs": [ | |
| { | |
| "output_type": "execute_result", | |
| "data": { | |
| "text/plain": "u'b08c8609-fb96-447f-beea-5df72e16aaf5'" | |
| }, | |
| "metadata": {}, | |
| "execution_count": 4 | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "trusted": true, | |
| "collapsed": true | |
| }, | |
| "cell_type": "code", | |
| "source": "uid = rs.uid", | |
| "execution_count": 5, | |
| "outputs": [] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": false, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "%timeit RunStart.objects(__raw__={'uid':uid}).first()", | |
| "execution_count": 6, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": "1000 loops, best of 3: 945 µs per loop\n", | |
| "name": "stdout" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": false, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "%timeit RunStart.objects(uid=uid).first()", | |
| "execution_count": 7, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": "1000 loops, best of 3: 968 µs per loop\n", | |
| "name": "stdout" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": false, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "%timeit RunStart.objects(uid=uid)[0]", | |
| "execution_count": 8, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": "1000 loops, best of 3: 903 µs per loop\n", | |
| "name": "stdout" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": false, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "%timeit RunStart.objects(__raw__={'uid':uid})[0]", | |
| "execution_count": 9, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": "1000 loops, best of 3: 891 µs per loop\n", | |
| "name": "stdout" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": false, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "%timeit RunStart.objects(uid=uid).get()", | |
| "execution_count": 10, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": "1000 loops, best of 3: 1.11 ms per loop\n", | |
| "name": "stdout" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": false, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "%timeit RunStart.objects(__raw__={'uid':uid}).get()", | |
| "execution_count": 11, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "text": "1000 loops, best of 3: 1.07 ms per loop\n", | |
| "name": "stdout" | |
| } | |
| ] | |
| }, | |
| { | |
| "metadata": { | |
| "collapsed": true, | |
| "trusted": true | |
| }, | |
| "cell_type": "code", | |
| "source": "", | |
| "execution_count": null, | |
| "outputs": [] | |
| } | |
| ], | |
| "metadata": { | |
| "kernelspec": { | |
| "name": "python2", | |
| "display_name": "Python 2", | |
| "language": "python" | |
| }, | |
| "language_info": { | |
| "mimetype": "text/x-python", | |
| "nbconvert_exporter": "python", | |
| "name": "python", | |
| "pygments_lexer": "ipython2", | |
| "version": "2.7.9", | |
| "file_extension": ".py", | |
| "codemirror_mode": { | |
| "version": 2, | |
| "name": "ipython" | |
| } | |
| }, | |
| "gist_id": "ca047302c2c1f1865415" | |
| }, | |
| "nbformat": 4, | |
| "nbformat_minor": 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment