On my machine, the timings are:
Fortran:
$ time ./a.out 249999999500000000 real 0m0.510s user 0m0.510s sys 0m0.000s
| # Author: Jacob Kristhammar, 2010 | |
| # | |
| # Updated version of websocket.py[1] that implements latest[2] stable version | |
| # of the websocket protocol. | |
| # | |
| # NB. It's no longer possible to manually select which callback that should | |
| # be invoked upon message reception. Instead you must override the | |
| # on_message(message) method to handle incoming messsages. | |
| # This also means that you don't have to explicitly invoke | |
| # receive_message, in fact you shouldn't. |
| """ | |
| This is a simple example of WebSocket + Tornado + Redis Pub/Sub usage. | |
| Do not forget to replace YOURSERVER by the correct value. | |
| Keep in mind that you need the *very latest* version of your web browser. | |
| You also need to add Jacob Kristhammar's websocket implementation to Tornado: | |
| Grab it here: | |
| http://gist.github.com/526746 | |
| Or clone my fork of Tornado with websocket included: | |
| http://github.com/pelletier/tornado | |
| Oh and the Pub/Sub protocol is only available in Redis 2.0.0: |
| #!/usr/bin/env python | |
| # -*- coding: utf8 -*- | |
| from flask import Flask, redirect, url_for | |
| from markdown import markdown | |
| import os | |
| import re | |
| # create the app | |
| # TODO: load config/template from files, with fallbacks |
| application: you-app-name-here | |
| version: 1 | |
| runtime: python | |
| api_version: 1 | |
| default_expiration: "30d" | |
| handlers: | |
| - url: /(.*\.(appcache|manifest)) | |
| mime_type: text/cache-manifest |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="author" content="" /> | |
| <meta name="copyright" content="" /> | |
| <meta name="robots" content="index, follow" /> |
| import errno | |
| import functools | |
| import socket | |
| from tornado import ioloop, iostream | |
| class Connection(object): | |
| def __init__(self, connection): | |
| self.stream = iostream.IOStream(connection) | |
| self._read() |
| program test | |
| implicit none | |
| integer, parameter :: dp = 8 | |
| real(dp) :: a, b | |
| a = 1.0_dp | |
| b = a + epsilon(1.0_dp) | |
| print *, "First we show, that we have two different 'a' and 'b':" | |
| print *, "a == b:", a == b, "b-a:", b-a | |
| print *, "using (es22.15)" | |
| print "(es22.15)", a |
| #!/usr/bin/env python | |
| """This is a demonstration of sharing file descriptors across processes. | |
| It uses Tornado (need a recent post-2.0 version from github) and the | |
| multiprocessing module (from python 2.6+). To run it, start one copy | |
| of fdserver.py and one or more copies of testserver.py (in different | |
| terminals, or backgrounded, etc). Fetch http://localhost:8000 and | |
| you'll see the requests getting answered by different processes (it's | |
| normal for several requests to go to the same process under light | |
| load, but under heavier load it tends to even out). |
On my machine, the timings are:
Fortran:
$ time ./a.out 249999999500000000 real 0m0.510s user 0m0.510s sys 0m0.000s
| <!-- Add the following lines to theme's html code right before </head> --> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script> | |
| <script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script> | |
| <script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script> | |
| <!-- | |
| Usage: just add <div class="gist">[gist URL]</div> | |
| Example: <div class="gist">https://gist.github.com/1395926</div> | |
| --> |