Skip to content

Instantly share code, notes, and snippets.

@devedetti
Created November 18, 2015 21:53
Show Gist options
  • Select an option

  • Save devedetti/5c33ac997d34424e6de9 to your computer and use it in GitHub Desktop.

Select an option

Save devedetti/5c33ac997d34424e6de9 to your computer and use it in GitHub Desktop.
pa los pibes
from random import randint
import time
from django.db import transaction
from mobile.models import Mobile, Phone, Handy, Tablet, MobileNetwork
from asset.models import Asset
ROWS = 1000
@transaction.atomic
def jojo():
a = time.time()
for i in xrange(ROWS):
p = Phone()
p.ram = randint(128, 2048)
p.storage = randint(1024, 1024 * 16)
p.os = 'iOS'
p.save()
p.networks.add(MobileNetwork.objects.get(pk=randint(1, 3)))
b = time.time()
for i in xrange(ROWS):
t = Tablet()
t.ram = randint(128, 2048)
t.storage = randint(1024, 1024 * 16)
t.os = 'Android'
t.save()
c = time.time()
for i in xrange(ROWS):
h = Handy()
h.ram = randint(128, 2048)
h.storage = randint(1024, 1024 * 16)
h.os = 'iOS'
h.frequency = 900
h.save()
d = time.time()
print 'Phone: {}'.format(b-a)
print 'Tablet: {}'.format(c-b)
print 'Handy: {}'.format(d-c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment