Skip to content

Instantly share code, notes, and snippets.

@maraca
Created February 3, 2011 00:13
Show Gist options
  • Save maraca/808795 to your computer and use it in GitHub Desktop.
Save maraca/808795 to your computer and use it in GitHub Desktop.
Just datastore
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext import db
import time
class User(db.Model):
"""Models """
name = db.StringProperty(required=True)
class MainHandler(webapp.RequestHandler):
def get(self):
init_time = time.time()
users = User.all()
end_time = time.time()
self.response.out.write('Total time : %f milliseconds ' %
(end_time - init_time) )
class PopulateHandler(webapp.RequestHandler):
def get(self):
for user in range(1000):
User(name=str(time.time())).put()
def main():
application = webapp.WSGIApplication([
('/', MainHandler),
('/populate/', PopulateHandler),
],
debug=True)
util.run_wsgi_app(application)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment