13 #define STATS_TC (TICKS_PER_SECOND_DBL)
14 static double inst_fps = 0.;
24 static int last_play_sequence = -1;
25 static ticks_t last_curr_tc = 0, currticks;
26 static ticks_t last_mini_ticks = 0;
28 boolean have_avsync =
FALSE;
29 char *msg, *audmsg = NULL, *bgmsg = NULL, *fgpal = NULL;
47 #ifdef HAVE_PULSE_AUDIO
61 last_curr_tc = currticks;
63 inst_fps =
cfile->pb_fps;
67 if (currticks > last_curr_tc +
STATS_TC) {
74 last_curr_tc = currticks;
79 if (calc_only)
return NULL;
83 tmp = lives_strdup(avsync >= 0. ?
_(
"ahead of") :
_(
"behind")), fabs(avsync));
87 else audmsg = (
_(
"Audio source external.\n"));
104 "Effort: %d / %d, quality: %d, %s (%s)\n%s\n"
105 "Fg clip: %d X %d, palette: %s\n%s"),
106 audmsg ? audmsg :
"",
115 fgpal, bgmsg ? bgmsg :
"");
124 #ifdef WEED_STARTUP_TESTS
128 #define PMISS 0.99609375
146 for (x = 0; x < NITERS; x++) {
151 for (d = 0; d < 64; d++) {
155 if (x && !(x & 1)) buckets[d][last[d] << 1]++;
159 if (x && !(x & 1)) buckets[d][(last[d] << 1) + 1]++;
166 dist[dval++][bval]++;
173 fprintf(stderr,
"Checking statistical probabilities\n");
174 for (x = 0; x < NITERS; x++) {
175 fprintf(stderr,
"%d %.4f ", x, 1. - prob);
178 fprintf(stderr,
"\n");
182 for (d = 0; d < 64; d++) {
183 fprintf(stderr,
"digit %d: score %d (%.2f%% 1s)\n", d, counter[d],
184 ((
double)counter[d] + (
double)NITERS) / (
double)NITERS * 50.);
185 fprintf(stderr,
"buckets: ");
186 for (x = 0; x < 4; x++) fprintf(stderr,
"[%d]: %d ", x, buckets[d][x]);
187 fprintf(stderr,
"\n");
189 for (d = 0; d < 8; d++) {
190 fprintf(stderr,
"segment %d: ", d);
191 for (x = 0; x < 256; x++) {
193 if (dval >= DTHRESH) fprintf(stderr,
"val %d / %d hit %d times ", d, x, dist[d][x]);
195 fprintf(stderr,
"\n");
202 static void show_timer_info(
void) {
203 g_print(
"\n\nTest completed in %.4f seconds\n\n",
208 static char *randstrg(
size_t len) {
210 for (
int i = 1; i < len; i++) *(ptr++) = ((
lives_random() & 63) + 32);
222 for (i = 0; i < nr; i++) {
228 for (i = 0; i < nr; i++) {
250 char *strg = randstrg(400);
251 char *strg2 = randstrg(500);
252 volatile size_t sz = 1;
254 memcpy(strg2, strg, 400);
255 for (j = 0; j < 5; j++) {
257 fprintf(stderr,
"test %d runs with lives_strlen()", nruns);
259 for (i = 0; i < nruns; i++) {
265 fprintf(stderr,
"test %d runs with strlen()", nruns);
267 for (i = 0; i < nruns; i++) {
268 sz = strcmp(strg, strg2);
281 lives_test_t *tt = (lives_test_t *)
lives_calloc(1,
sizeof(lives_test_t)), *tt2;
283 lsd = lsd_create(
"lives_test_t",
sizeof(lives_test_t),
"strgs", 1);
286 &tt->strg,
"strg", 0,
288 lives_struct_init(lsd, tt, &tt->lsd);
292 for (
int i = 0; i < 1000000; i++) {
293 tt = lives_struct_create(lsd);
294 tt->strg = strdup(
"a string to be copied !");
304 tt2 = lives_struct_copy(&tt->lsd);
312 lives_struct_free(&tt->lsd);
313 lives_struct_free(&tt2->lsd);
322 int run_weed_startup_tests(
void) {
324 int a, type, ne, st, flags;
336 g_print(
"Testing libweed functionality:\n\n");
341 plant = weed_plant_new(WEED_PLANT_HOST_INFO);
342 fprintf(stderr,
"plant is %p\n", plant);
344 fprintf(stderr,
"\n");
345 show_quadstate(plant);
346 fprintf(stderr,
"\n");
348 type = weed_get_int_value(plant, WEED_LEAF_TYPE, &werr);
349 fprintf(stderr,
"type is %d, err was %d\n", type, werr);
351 ne = weed_leaf_num_elements(plant, WEED_LEAF_TYPE);
352 fprintf(stderr,
"ne was %d\n", ne);
354 st = weed_leaf_seed_type(plant,
"type");
355 fprintf(stderr,
"seedtype is %d\n", st);
357 flags = weed_leaf_get_flags(plant, WEED_LEAF_TYPE);
358 fprintf(stderr,
"flags is %d\n", flags);
362 keys = weed_plant_list_leaves(plant, &nleaves);
364 while (keys[n] != NULL) {
365 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
370 fprintf(stderr,
"\n");
371 show_quadstate(plant);
372 fprintf(stderr,
"\n");
375 fprintf(stderr,
"check NULL plant\n");
376 type = weed_get_int_value(NULL, WEED_LEAF_TYPE, &werr);
378 fprintf(stderr,
"type is %d, err was %d\n", type, werr);
379 ne = weed_leaf_num_elements(NULL, WEED_LEAF_TYPE);
381 fprintf(stderr,
"ne was %d\n", ne);
382 st = weed_leaf_seed_type(NULL,
"type");
384 fprintf(stderr,
"seedtype is %d\n", st);
385 flags = weed_leaf_get_flags(NULL, WEED_LEAF_TYPE);
387 fprintf(stderr,
"flags is %d\n", flags);
389 keys = weed_plant_list_leaves(NULL, NULL);
391 while (keys[n] != NULL) {
392 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
397 fprintf(stderr,
"\n");
398 show_quadstate(plant);
399 fprintf(stderr,
"\n");
404 fprintf(stderr,
"zzztype setfff\n");
405 werr = weed_leaf_set_flags(plant,
"type", 0);
406 fprintf(stderr,
"zzztype setflags %d\n", werr);
409 fprintf(stderr,
"Check NULL key \n");
411 type = weed_get_int_value(plant, NULL, &werr);
412 fprintf(stderr,
"type is %d, err was %d\n", type, werr);
414 fprintf(stderr,
"\n");
415 show_quadstate(plant);
416 fprintf(stderr,
"\n");
420 ne = weed_leaf_num_elements(plant, NULL);
421 fprintf(stderr,
"ne was %d\n", ne);
423 fprintf(stderr,
"\n");
424 show_quadstate(plant);
425 fprintf(stderr,
"\n");
430 st = weed_leaf_seed_type(plant, NULL);
431 fprintf(stderr,
"seedtype is %d\n", st);
433 fprintf(stderr,
"\n");
434 show_quadstate(plant);
435 fprintf(stderr,
"\n");
438 flags = weed_leaf_get_flags(plant, NULL);
439 fprintf(stderr,
"flags is %d\n", flags);
441 fprintf(stderr,
"\n");
442 show_quadstate(plant);
443 fprintf(stderr,
"\n");
445 fprintf(stderr,
"Check zero key \n");
446 type = weed_get_int_value(plant,
"", &werr);
448 fprintf(stderr,
"\n");
449 show_quadstate(plant);
450 fprintf(stderr,
"\n");
454 fprintf(stderr,
"type is %d, err was %d\n", type, werr);
455 ne = weed_leaf_num_elements(plant,
"");
457 fprintf(stderr,
"\n");
458 show_quadstate(plant);
459 fprintf(stderr,
"\n");
461 fprintf(stderr,
"ne was %d\n", ne);
462 st = weed_leaf_seed_type(plant,
"");
464 fprintf(stderr,
"seedtype is %d\n", st);
465 flags = weed_leaf_get_flags(plant,
"");
466 fprintf(stderr,
"flags is %d\n", flags);
468 fprintf(stderr,
"\n");
469 show_quadstate(plant);
470 fprintf(stderr,
"\n");
472 fprintf(stderr,
"checking get / set values\n");
474 weed_set_int_value(plant,
"Test", 99);
475 fprintf(stderr,
"Set 'Test' = 99\n");
477 fprintf(stderr,
"\n");
478 show_quadstate(plant);
479 fprintf(stderr,
"\n");
481 a = weed_get_int_value(plant,
"Test", &werr);
483 fprintf(stderr,
"value read was %d, err was %d\n", a, werr);
485 fprintf(stderr,
"\n");
486 show_quadstate(plant);
487 fprintf(stderr,
"\n");
489 keys = weed_plant_list_leaves(plant, &nleaves);
491 while (keys[n] != NULL) {
492 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
498 fprintf(stderr,
"\n");
499 show_quadstate(plant);
500 fprintf(stderr,
"\n");
502 weed_set_int_value(plant,
"Test", 143);
503 a = weed_get_int_value(plant,
"Test", &werr);
505 fprintf(stderr,
"value read was %d, err was %d\n", a, werr);
507 keys = weed_plant_list_leaves(plant, &nleaves);
509 while (keys[n] != NULL) {
510 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
515 fprintf(stderr,
"\n");
516 show_quadstate(plant);
517 fprintf(stderr,
"\n");
519 weed_set_string_value(plant,
"Test2",
"abc");
520 str = weed_get_string_value(plant,
"Test2", &werr);
522 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
524 keys = weed_plant_list_leaves(plant, &nleaves);
526 while (keys[n] != NULL) {
527 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
533 weed_set_string_value(plant,
"Test2",
"12345");
534 str = weed_get_string_value(plant,
"Test2", &werr);
536 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
538 keys = weed_plant_list_leaves(plant, &nleaves);
540 while (keys[n] != NULL) {
541 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
546 fprintf(stderr,
"\n");
547 show_quadstate(plant);
548 fprintf(stderr,
"\n");
550 weed_set_string_value(plant,
"Test2",
"");
551 str = weed_get_string_value(plant,
"Test2", &werr);
553 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
555 keys = weed_plant_list_leaves(plant, &nleaves);
557 while (keys[n] != NULL) {
558 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
564 weed_set_string_value(plant,
"Test2", NULL);
565 str = weed_get_string_value(plant,
"Test2", &werr);
567 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
569 keys = weed_plant_list_leaves(plant, &nleaves);
571 while (keys[n] != NULL) {
572 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
577 fprintf(stderr,
"\n");
578 show_quadstate(plant);
579 fprintf(stderr,
"\n");
581 weed_set_string_value(plant,
"Test3", NULL);
582 str = weed_get_string_value(plant,
"Test3", &werr);
584 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
586 keys = weed_plant_list_leaves(plant, &nleaves);
588 while (keys[n] != NULL) {
589 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
594 fprintf(stderr,
"\n");
595 show_quadstate(plant);
596 fprintf(stderr,
"\n");
598 weed_set_string_value(plant, NULL, NULL);
599 str = weed_get_string_value(NULL, NULL, &werr);
601 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
603 keys = weed_plant_list_leaves(plant, &nleaves);
605 while (keys[n] != NULL) {
606 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
611 fprintf(stderr,
"\n");
612 show_quadstate(plant);
613 fprintf(stderr,
"\n");
620 werr = weed_set_int_array(plant,
"intarray", 4, pint);
621 fprintf(stderr,
"int array set, err was %d\n", werr);
623 intpr = weed_get_int_array(plant,
"intarray", &werr);
624 fprintf(stderr,
"int array got %d %d %d %d , err was %d\n", intpr[0], intpr[1], intpr[2], intpr[3], werr);
626 intpr = weed_get_int_array(plant,
"xintarray", &werr);
627 fprintf(stderr,
"int array got %p, err was %d\n", intpr, werr);
629 intpr = weed_get_int_array(NULL,
"xintarray", &werr);
630 fprintf(stderr,
"int array got %p , err was %d\n", intpr, werr);
632 fprintf(stderr,
"\n");
633 show_quadstate(plant);
634 fprintf(stderr,
"\n");
636 fprintf(stderr,
"\n\nflag tests\n");
638 flags = weed_leaf_get_flags(plant,
"type");
639 fprintf(stderr,
"type flags (0) are %d\n", flags);
641 fprintf(stderr,
"\n");
642 show_quadstate(plant);
643 fprintf(stderr,
"\n");
645 a = weed_get_int_value(plant,
"type", &werr);
646 fprintf(stderr,
"get type returned %d %d\n", a, werr);
648 fprintf(stderr,
"\n");
649 show_quadstate(plant);
650 fprintf(stderr,
"\n");
652 werr = weed_set_int_value(plant,
"type", 99);
653 fprintf(stderr,
"set type returned %d\n", werr);
655 fprintf(stderr,
"\n");
656 show_quadstate(plant);
657 fprintf(stderr,
"\n");
659 a = weed_get_int_value(plant,
"type", &werr);
660 fprintf(stderr,
"get type returned %d %d\n", a, werr);
662 fprintf(stderr,
"\n");
663 show_quadstate(plant);
664 fprintf(stderr,
"\n");
666 flags = weed_leaf_get_flags(plant,
"type");
667 fprintf(stderr,
"type flags (1) are %d\n", flags);
669 fprintf(stderr,
"\n");
670 show_quadstate(plant);
671 fprintf(stderr,
"\n");
673 werr = weed_leaf_set_flags(plant,
"type", 0);
674 fprintf(stderr,
"type setflags %d\n", werr);
676 fprintf(stderr,
"\n");
677 show_quadstate(plant);
678 fprintf(stderr,
"\n");
680 flags = weed_leaf_get_flags(plant,
"type");
681 fprintf(stderr,
"type flags (1a) are %d\n", flags);
683 fprintf(stderr,
"\n");
684 show_quadstate(plant);
685 fprintf(stderr,
"\n");
690 werr = weed_set_int_value(plant,
"type", 123);
691 fprintf(stderr,
"set type returned %d\n", werr);
693 fprintf(stderr,
"\n");
694 show_quadstate(plant);
695 fprintf(stderr,
"\n");
700 a = weed_get_int_value(plant,
"type", &werr);
701 fprintf(stderr,
"get type returned %d %d\n", a, werr);
704 fprintf(stderr,
"\n");
705 show_quadstate(plant);
706 fprintf(stderr,
"\n");
710 flags = weed_leaf_get_flags(plant,
"type");
711 fprintf(stderr,
"type flags (2) are %d\n", flags);
713 fprintf(stderr,
"\n");
714 show_quadstate(plant);
715 fprintf(stderr,
"\n");
719 werr = weed_leaf_set_flags(plant,
"type", WEED_FLAG_IMMUTABLE);
720 fprintf(stderr,
"type setflags %d\n", werr);
722 werr = weed_set_int_value(plant,
"type", 200);
723 fprintf(stderr,
"set type returned %d\n", werr);
725 flags = weed_leaf_get_flags(plant,
"type");
726 fprintf(stderr,
"type flags (3) are %d\n", flags);
728 flags = weed_leaf_get_flags(plant,
"Test2");
729 fprintf(stderr,
"test getflags %d\n", flags);
731 weed_set_string_value(plant,
"Test2",
"abcde");
732 str = weed_get_string_value(plant,
"Test2", &werr);
734 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
736 keys = weed_plant_list_leaves(plant, &nleaves);
738 while (keys[n] != NULL) {
739 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
745 weed_set_string_value(plant,
"Test2",
"888888");
746 str = weed_get_string_value(plant,
"Test2", &werr);
748 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
750 weed_leaf_set_flags(plant,
"Test2", WEED_FLAG_IMMUTABLE);
752 werr = weed_set_string_value(plant,
"Test2",
"hello");
753 fprintf(stderr,
"set immutable returned %d\n", werr);
755 str = weed_get_string_value(plant,
"Test2", &werr);
757 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
759 weed_leaf_set_flags(plant,
"Test2", 0);
761 weed_set_string_value(plant,
"Test2",
"OK");
762 str = weed_get_string_value(plant,
"Test2", &werr);
764 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
766 weed_set_string_value(plant,
"string1",
"abccc");
767 weed_set_string_value(plant,
"string2",
"xyyyyzz");
768 weed_set_string_value(plant,
"string3",
"11111 11111");
770 werr = weed_set_string_value(plant,
"string2",
"xxxxx");
771 str = weed_get_string_value(plant,
"string2", &werr);
772 fprintf(stderr,
"value read was %s, err was %d\n", str, werr);
775 fprintf(stderr,
"\n");
776 show_quadstate(plant);
777 fprintf(stderr,
"\n");
780 keys = weed_plant_list_leaves(plant, &nleaves);
782 while (keys[n] != NULL) {
783 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
790 werr = weed_leaf_delete(plant,
"string1");
791 fprintf(stderr,
"del leaf returned %d\n", werr);
795 keys = weed_plant_list_leaves(plant, &nleaves);
797 while (keys[n] != NULL) {
798 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
804 str = weed_get_string_value(plant,
"string1", &werr);
805 fprintf(stderr,
"del leaf returned %s %d\n", str, werr);
807 flags = weed_leaf_get_flags(plant,
"string2");
808 fprintf(stderr,
"get flags returned %d\n", flags);
809 weed_leaf_set_flags(plant,
"string2", WEED_FLAG_UNDELETABLE);
810 flags = weed_leaf_get_flags(plant,
"string2");
811 fprintf(stderr,
"get flags returned %d\n", flags);
813 werr = weed_leaf_delete(plant,
"string2");
814 fprintf(stderr,
"del aaa leaf returned %d\n", werr);
815 str = weed_get_string_value(plant,
"string2", &werr);
816 fprintf(stderr,
"del zzz leaf returned %s %d\n", str, werr);
819 weed_leaf_set_flags(plant,
"string2", 0);
820 flags = weed_leaf_get_flags(plant,
"string2");
821 fprintf(stderr,
"set flags returned %d\n", flags);
822 werr = weed_leaf_delete(plant,
"string2");
823 fprintf(stderr,
"del yyy leaf returned %d\n", werr);
825 str = weed_get_string_value(plant,
"string2", &werr);
826 fprintf(stderr,
"del xxx leaf val returned %s %d\n", str, werr);
830 werr = weed_leaf_set_flags(plant,
"Test2", WEED_FLAG_UNDELETABLE);
832 flags = weed_leaf_get_flags(plant,
"string2");
833 fprintf(stderr,
"get flags returned %d\n", flags);
835 werr = weed_plant_free(plant);
836 fprintf(stderr,
"wpf returned %d\n", werr);
840 keys = weed_plant_list_leaves(plant, &nleaves);
842 while (keys[n] != NULL) {
843 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
851 werr = weed_set_voidptr_value(plant,
"nullptr", NULL);
852 fprintf(stderr,
"set null void * returned %d\n", werr);
854 ptr = weed_get_voidptr_value(plant,
"nullptr", &werr);
855 fprintf(stderr,
"get null vooid * returned (%p) %d\n", ptr, werr);
857 ptr = weed_get_voidptr_value(plant,
"nullptrxx", &werr);
858 fprintf(stderr,
"get nonexist void * returned (%p) %d\n", ptr, werr);
865 ptr = weed_get_voidptr_value(plant,
"nullbasic", &werr);
866 fprintf(stderr,
"get null basic voidptr 0 returned (%p) %d\n", ptr, werr);
870 keys = weed_plant_list_leaves(plant, &nleaves);
872 while (keys[n] != NULL) {
873 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
883 ptr = weed_get_voidptr_value(plant,
"nullbasic", &werr);
884 fprintf(stderr,
"get null string returned (%p) %d\n", ptr, werr);
890 ptr = weed_get_voidptr_value(plant,
"indirect", &werr);
891 fprintf(stderr,
"get null string returned (%p) %d\n", ptr, werr);
898 weed_leaf_set(plant,
"ptrs", WEED_SEED_VOIDPTR, 4, &ptra);
899 fprintf(stderr,
"set null array elem ptra returned %d\n", werr);
901 void **ptrb = weed_get_voidptr_array(plant,
"ptrs", &werr);
902 fprintf(stderr,
"get void ** returned (%p %p %p %p) %d\n", ptrb[0], ptrb[1], ptrb[2], ptrb[3], werr);
909 weed_leaf_set(plant,
"ptrs", WEED_SEED_VOIDPTR, 4, &ptra);
910 fprintf(stderr,
"set null array elem ptra returned %d\n", werr);
912 ptrb = weed_get_voidptr_array(plant,
"ptrs", &werr);
913 fprintf(stderr,
"get void ** returned (%p %p %p %p) %d\n", ptrb[0], ptrb[1], ptrb[2], ptrb[3], werr);
915 weed_leaf_set(plant,
"strings", WEED_SEED_STRING, 4, &s);
916 fprintf(stderr,
"set char ** %d\n", werr);
919 stng2 = weed_get_string_array(plant,
"strings", &werr);
920 fprintf(stderr,
"get char ** returned (%s %s %s %s) %d\n", stng2[0], stng2[1], stng2[2], stng2[3], werr);
922 werr = weed_leaf_set(plant,
"arrawn", WEED_SEED_VOIDPTR, 4, ptra);
923 fprintf(stderr,
"set null array returned %d\n", werr);
925 keys = weed_plant_list_leaves(plant, &nleaves);
927 while (keys[n] != NULL) {
928 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
934 flags = weed_leaf_get_flags(plant,
"Test2");
935 fprintf(stderr,
"get flags for Test2returned %d\n", flags);
937 werr = weed_leaf_set_flags(plant,
"Test2", WEED_FLAG_UNDELETABLE);
938 flags = weed_leaf_get_flags(plant,
"string2");
940 fprintf(stderr,
"get flags for Test2returned %d\n", flags);
942 werr = weed_leaf_set_flags(plant,
"Test2", 0);
943 flags = weed_leaf_get_flags(plant,
"string2");
945 fprintf(stderr,
"get flags for Test2returned %d\n", flags);
947 werr = weed_leaf_set_flags(plant,
"type", WEED_FLAG_UNDELETABLE | WEED_FLAG_IMMUTABLE);
948 fprintf(stderr,
"wlsf for type returned %d\n", werr);
952 flags = weed_leaf_get_flags(plant,
"type");
953 fprintf(stderr,
"get type flags returned %d\n", flags);
955 werr = weed_plant_free(plant);
956 fprintf(stderr,
"wpf returned %d\n", werr);
958 keys = weed_plant_list_leaves(plant, &nleaves);
960 while (keys[n] != NULL) {
961 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
967 werr = weed_leaf_set_flags(plant,
"type", WEED_FLAG_IMMUTABLE);
968 flags = weed_leaf_get_flags(plant,
"type");
969 fprintf(stderr,
"get flags returned %d\n", flags);
971 werr = weed_leaf_set_flags(plant,
"arrawn", WEED_FLAG_UNDELETABLE);
972 fprintf(stderr,
"set flags returned %d\n", werr);
974 flags = weed_leaf_get_flags(plant,
"arrawn");
975 fprintf(stderr,
"get flags returned %d\n", flags);
977 werr = weed_leaf_set_flags(plant,
"indirect", WEED_FLAG_UNDELETABLE);
978 werr = weed_leaf_set_flags(plant,
"Test2", WEED_FLAG_UNDELETABLE);
980 werr = weed_plant_free(plant);
981 fprintf(stderr,
"wpf returned %d\n", werr);
983 keys = weed_plant_list_leaves(plant, &nleaves);
985 while (keys[n] != NULL) {
986 fprintf(stderr,
"key %d is %s\n", n, keys[n]);
992 werr = weed_leaf_set_flags(plant,
"arrawn", 0);
993 fprintf(stderr,
"set flags returned %d\n", werr);
994 flags = weed_leaf_get_flags(plant,
"arrawn");
995 fprintf(stderr,
"get flags returned %d\n", flags);
997 werr = weed_leaf_set_flags(plant,
"indirect", WEED_FLAG_IMMUTABLE);
998 werr = weed_leaf_set_flags(plant,
"Test2", 0);
1000 werr = weed_plant_free(plant);
1001 fprintf(stderr,
"wpf returned %d\n", werr);
1016 #define BPLANT_LEAVES 10000
1017 g_print(
"Big plant test: \n");
1018 g_print(
"adding %d leaves\n", BPLANT_LEAVES);
1019 plant = weed_plant_new(WEED_PLANT_EVENT);
1020 for (
int i = 0; i < BPLANT_LEAVES; i++) {
1023 weed_set_int_value(plant, key, num);
1027 g_print(
"test %d random reads\n", BPLANT_LEAVES * 10);
1029 for (
int i = 0; i < BPLANT_LEAVES * 10; i++) {
1031 weed_get_int_value(plant, key, &werr);
1032 if (werr == WEED_SUCCESS) n++;
1035 g_print(
"done, hit percentage was %.2f\n", (
double)n / (
double)BPLANT_LEAVES * 10);
1038 g_print(
"test %d last-leaf reads\n", BPLANT_LEAVES * 10);
1040 for (
int i = 0; i < BPLANT_LEAVES * 10; i++) {
1041 const char *key =
"leaf_number_0";
1042 weed_get_int_value(plant, key, &werr);
1043 if (werr == WEED_SUCCESS) n++;
1045 g_print(
"done, hit percentage was %.2f\n", (
double)n / (
double)BPLANT_LEAVES * 10);
1048 g_print(
"freeing big plant\n");
1049 weed_plant_free(plant);
1053 plant = weed_plant_new(0);
1054 if (weed_leaf_set_private_data(plant, WEED_LEAF_TYPE, NULL) == WEED_ERROR_CONCURRENCY) {
1056 g_print(
"libweed built with FULL threadsafety\n");
1059 g_print(
"libweed built with PARTIAL threadsafety\n");
1061 weed_plant_free(plant);
1070 #define SCALE_FACT 65793.
1075 for (val = 0.; val < 256.; val += .1) {
1078 if (fabs((
float)outval - val) > .51)
1079 g_print(
"in val was %.6f, stored as %d, returned as %d\n", val, inval, outval);