This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On Wed, Oct 08, 2014 at 10:32:40AM +0200, Leonhard Holz wrote: > Defensive programming... the input files are all generated and might be > regenerated by some else in the future. Fair enough. > Is this really an issue? It's only four times the size of a pointer, the > benchmark is not affected by it and the malloc's will not make the > code nicer. It does make the code better in addition to the fact that it is more familiar coding style; I've elaborated on the 'how' below. In general the number of copies of the struct in all those functions is just wasteful. It may not affect the benchmark, but that's no reason to keep it sloppy. > The idea is to set a fallback locale at the beginning which is used if one > of the benchmarked locales are not available. This is why the used locale is > also printed in the results. So you want it to skip the run if the needed > locale is not available? The test should fail with an error, because the locale should always be available in this test - we're generating them. In fact, I think we might need to wire things up so that locales are generated during `make bench`. I don't think that's happening currently because they're currently generated as part of `make check`. > >> char *text = read_file (filename); > >> word_list list = tokenize_string (text, delim); > >> > >> word_list *tests = malloc (INNER_LOOP_ITERS * sizeof (word_list)); > >> for (i = 0; i < INNER_LOOP_ITERS; i++) > >> tests[i] = copy_word_list (list); > > > >This will obviously have to be adjusted (and hence made cleaner) once > >copy_word_list and all other functions above pass pointers to > >word_list. > > Maybe I'll see when I change it but maybe you can give me a hint what you > mean with "cleaner". Your word_list API (for the lack of a better term) becomes cleaner: 1. tokenize_string should allocate and returns a word_list. You can rename it to new_word_list to make it more consistent 2. copy_word_list allocates (and copies) and returns a word_list 3. free_word_list frees the word_list Everything else just uses the reference and can hence modify the list in place. sort_word_list for example would no longer need to create a copy of the passed in object. Oh, and it looks like sort_word_list is unused, so you can just remove it. > Is there some code that can be reused for output in JSON format? See bench-skeleton.c for an example. Or maybe the malloc benchmark patch that Will Newton posted recently[1]. Siddhesh [1] http://patchwork.sourceware.org/patch/3092/
Attachment:
pgpMj0fjTJ_yC.pgp
Description: PGP signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |