Thank you, Bruno.

My program running ok with your guide.

My goal is to compare the ORM performance of Django and
TurboGears(SQLObject or SQLAlchemy).

So write the test scripts.

To process 1000 times data, django's test result is below:

Insert Speed: 0.766191005707
Select Speed: 0.027615070343
Update Speed: 3.05239295959
Drop Speed: 0.941470146179

It looks not very good, my codes need more optimization.

PS: I don't want to delete the p1 from database, just want to unset
the variable. So use the del p1 and not p1.delete()


On Oct 8, 5:54 am, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 7 oct, 17:54, "K*K" <[EMAIL PROTECTED]> wrote:
>
> > Hi, all
>
> > I'm writing a program to test django's mysql performance, use timeit
> > to profile. But it make my app into infinite loop.
>
> I'm probably a bit tired, but I don't see how the below snippet could
> cause an infinite loop - unless you did something very wrong in the
> parts of the code that are called but you didn't post.
>
> > always write data
> > into database.
>
> Err... Wait... This is what asked for, didn't you ? (cf below...)
>
> > <pre>
> > import timeit
>
> > from django.shortcuts import render_to_response
> > from testDjango.benchmark.models import Django
>
> > loop_range = 10
>
> > def benchmark(request):
> >         global loop_range
>
> <OT>
> You don't need the global statement here since you're not rebinding
> loop_range. FWIW, you could declare it as a local variable anyway
> </OT>
>
> >         insert_timer = timeit.Timer("benchmark_insert()", "from
> > testDjango.bench import benchmark_insert")
> >         insert_timer.repeat(loop_range)
> >         insert_speed = insert_timer.timeit()
>
> I suspect you misread the doc for timer.repeat and timer.timeit.
> Timer.timeit will already repeat the given statement quite a few times
> (1000000 by default). Timer.repeat will call Timer.timeit x times. So
> with your above code, you will first call benchmark_insert() 10 *
> 1000000 times, discard the result, then call benchmark_insert()
> 1000000 more times.
>
> If you meant to only call Timer.timeit once and make it call
> benchmark_insert only 10 times, you want :
>
>       insert_timer = timeit.Timer(
>           "benchmark_insert()",
>           "from testDjango.bench import benchmark_insert"
>           )
>       insert_speed = insert_timer.timeit(loop_range)
>
> > def benchmark_insert():
> >         p1 = Django(foobar='Test foo',)
> >         p1.save()
> >         del p1
>
> I think you meant p1.delete().  'del p1' unbind the name p1 in the
> current namespace - which is pretty useless here FWIW -, but won't
> remove anything from your database.
>
> HTH
>
> > </pre>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to