On Oct 15, 11:27 am, Sam Lai <samuel....@gmail.com> wrote:
> I haven't looked at your code yet (I will soon), but I'm just curious
> if your changes have had any impact on performance? I remember that
> when I set out to implement some of this code, I had issues with it
> being efficient when there are larger sets of tags, including
> excessive database calls, or excessive data parsing.

Unfortunatelly the branch is slower yes. Thats a bad thing ofcourse
but a
simple test revealed that the parse_tag_input must be the bottleneck.
I changed
this function to rely on regexps instead of simple char-by-char
parsing and
i think this slowed things down.

Maybe i can rewrite this function again to avoid regexps. I'll let you
know
when i've tried something new in this function to speed things up.


Here are also the results from a very simplistic performance test
suite.
Every test were run with 10000 tags in string representation.
MachineTags are tags with namespaces, names and values (each 5
characters
long). NamespacedTags are tags with namespaces (5 chars) and names (10
chars).
NormalTags are tags without any namespace and value, the names are
15 chars long.

At first the results for the original tagging application:

----------------------------------------
MachineTags
test1_parse_tag_input 0.09s
test2_insert_tags 9.76s
test3_get_tag_list 0.87s
test4_get_tag 4.85s
MachineTags, total time: 15.57s

NamespacedTags
test1_parse_tag_input 0.09s
test2_insert_tags 9.69s
test3_get_tag_list 0.85s
test4_get_tag 4.81s
NamespacedTags, total time: 15.44s

NormalTags
test1_parse_tag_input 0.09s
test2_insert_tags 9.70s
test3_get_tag_list 0.85s
test4_get_tag 4.81s
NormalTags, total time: 15.44s
----------------------------------------


And the results for the machinetags branch:

----------------------------------------
MachineTags
test1_parse_tag_input 0.43s
test2_insert_tags 13.19s
test3_get_tag_list 6.37s
test4_get_tag 7.45s
MachineTags, total time: 27.43s

NamespacedTags
test1_parse_tag_input 0.34s
test2_insert_tags 12.94s
test3_get_tag_list 6.13s
test4_get_tag 7.40s
NamespacedTags, total time: 26.81s

NormalTags
test1_parse_tag_input 0.10s
test2_insert_tags 12.75s
test3_get_tag_list 17.59s
test4_get_tag 7.28s
NormalTags, total time: 37.72s
----------------------------------------



Here are the test methods:


    def test1_parse_tag_input(self):
        for tag in self.tags:
            parse_tag_input(tag)

    def pre_test2_insert_tags(self):
        self.articles = []
        for i in range(len(self.tags) / 10):
            self.articles.append(Article.objects.create(name=i))

    def post_test2_insert_tags(self):
        Article.objects.all().delete()

    def test2_insert_tags(self):
        for i, a in enumerate(Article.objects.all()):
            Tag.objects.update_tags(a, ', '.join(self.tags
[i*10:i*10+10]))

    def test3_get_tag_list(self):
        for i in range(0, len(self.tags), 10):
            l = get_tag_list(', '.join(self.tags[i:i+10]))
            assert len(l) == 10, len(l)

    def test4_get_tag(self):
        for tag in self.tags:
            assert get_tag(tag)


Gregor

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to