| 2943 | // KdW test -- use original v31 "for auto" code |
| 2944 | // CRASH 20200406-1658 |
| 2945 | #if 0 |
| 2946 | for (int i=0; i<100000; i++) |
| 2947 | { |
| 2948 | int j = 0; |
| 2949 | for (auto iter2 = m_encoderList->begin(); iter2 != m_encoderList->end(); ++iter2) |
| 2950 | { |
| 2951 | j++; |
| 2952 | EncoderLink *elink2 = *iter2; |
| 2953 | if (elink2->IsLocal()) |
| 2954 | { |
| 2955 | (void) iter2.key(); |
| 2956 | } |
| 2957 | } |
| 2958 | } |
| 2959 | #endif |
| 2960 | |
| 2961 | // KdW test -- use original v31 "for auto" code but now with const |
| 2962 | // OK 20200406-1655 |
| 2963 | #if 0 |
| 2964 | for (int i=0; i<100000; i++) |
| 2965 | { |
| 2966 | int j = 0; |
| 2967 | for (auto iter2 = m_encoderList->constBegin(); iter2 != m_encoderList->constEnd(); ++iter2) |
| 2968 | { |
| 2969 | j++; |
| 2970 | EncoderLink *elink2 = *iter2; |
| 2971 | if (elink2->IsLocal()) |
| 2972 | { |
| 2973 | (void) iter2.key(); |
| 2974 | } |
| 2975 | } |
| 2976 | } |
| 2977 | #endif |
| 2978 | |
| 2979 | // KdW test -- use Java-style iteration, example from https://doc.qt.io/qt-5/qmap.html |
| 2980 | // OK 20200405 |
| 2981 | #if 0 |
| 2982 | int j = 0; |
| 2983 | for (int i=0; i<100000; i++) |
| 2984 | { |
| 2985 | QMapIterator<int, EncoderLink *> z(*m_encoderList); |
| 2986 | while (z.hasNext()) |
| 2987 | { |
| 2988 | z.next(); |
| 2989 | EncoderLink *elink2 = z.value(); |
| 2990 | if (elink2->IsLocal()) |
| 2991 | { |
| 2992 | (void) z.key(); |
| 2993 | j++; |
| 2994 | } |
| 2995 | } |
| 2996 | } |
| 2997 | cout << "KdW test test j:" << j << endl; |
| 2998 | #endif |
| 2999 | |
| 3000 | // KdW test -- use STL-style iteration, example from https://doc.qt.io/qt-5/qmap.html |
| 3001 | // Uses const |
| 3002 | // OK 202004306-1647 |
| 3003 | #if 0 |
| 3004 | for (int i=0; i<100000; i++) |
| 3005 | { |
| 3006 | int j = 0; |
| 3007 | QMap<int, EncoderLink*>::const_iterator iter2 = m_encoderList->constBegin(); |
| 3008 | while (iter2 != m_encoderList->constEnd()) |
| 3009 | { |
| 3010 | j++; |
| 3011 | EncoderLink *elink2 = *iter2; |
| 3012 | if (elink2->IsLocal()) |
| 3013 | { |
| 3014 | (void) iter2.key(); |
| 3015 | } |
| 3016 | iter2++; |
| 3017 | } |
| 3018 | } |
| 3019 | #endif |
| 3020 | |
| 3021 | // KdW test -- use STL-style iteration, example from https://doc.qt.io/qt-5/qmap.html |
| 3022 | // No const |
| 3023 | // CRASH 20200406 |
| 3024 | #if 0 |
| 3025 | for (int i=0; i<100000; i++) |
| 3026 | { |
| 3027 | int j = 0; |
| 3028 | QMap<int, EncoderLink*>::iterator iter2 = m_encoderList->begin(); |
| 3029 | while (iter2 != m_encoderList->end()) |
| 3030 | { |
| 3031 | j++; |
| 3032 | EncoderLink *elink2 = *iter2; |
| 3033 | if (elink2->IsLocal()) |
| 3034 | { |
| 3035 | (void) iter2.key(); |
| 3036 | } |
| 3037 | iter2++; |
| 3038 | } |
| 3039 | } |
| 3040 | #endif |
| 3041 | |
| 3042 | // KdW test -- use v30 original code STL-style iteration |
| 3043 | // CRASH 20200406-1835 |
| 3044 | #if 0 |
| 3045 | for (int i=0; i<100000; i++) |
| 3046 | { |
| 3047 | int j = 0; |
| 3048 | QMap<int, EncoderLink *>::Iterator iter2 = m_encoderList->begin(); |
| 3049 | for (; iter2 != m_encoderList->end(); ++iter2) |
| 3050 | { |
| 3051 | j++; |
| 3052 | EncoderLink *elink2 = *iter2; |
| 3053 | if (elink2->IsLocal()) |
| 3054 | { |
| 3055 | (void) iter2.key(); |
| 3056 | } |
| 3057 | } |
| 3058 | } |
| 3059 | #endif |
| 3060 | |
| 3061 | // KdW test -- use v30 original code STL-style iteration |
| 3062 | // Use const |
| 3063 | // OK 20200406-2105 |
| 3064 | #if 0 |
| 3065 | for (int i=0; i<100000; i++) |
| 3066 | { |
| 3067 | int j = 0; |
| 3068 | QMap<int, EncoderLink *>::const_iterator iter2 = m_encoderList->constBegin(); |
| 3069 | for (; iter2 != m_encoderList->constEnd(); ++iter2) |
| 3070 | { |
| 3071 | j++; |
| 3072 | EncoderLink *elink2 = *iter2; |
| 3073 | if (elink2->IsLocal()) |
| 3074 | { |
| 3075 | (void) iter2.key(); |
| 3076 | } |
| 3077 | } |
| 3078 | } |
| 3079 | #endif |
| 3080 | |
| 3081 | // KdW test -- use foreach loop |
| 3082 | // OK 20200406-2032 |
| 3083 | #if 0 |
| 3084 | for (int i=0; i<100000; i++) |
| 3085 | { |
| 3086 | int j = 0; |
| 3087 | |
| 3088 | foreach (int key, m_encoderList->keys()) |
| 3089 | { |
| 3090 | EncoderLink *elink2 = m_encoderList->value(key); |
| 3091 | if (elink2->IsLocal()) |
| 3092 | { |
| 3093 | j++;; |
| 3094 | } |
| 3095 | } |
| 3096 | } |
| 3097 | #endif |
| 3098 | |
| 3099 | // KdW test -- Compare the old values with the current contents |
| 3100 | // This also shows a crash and sometimes a value from another entry and sometimes garbage |
| 3101 | #if 0 |
| 3102 | for (int i=0; i<10000; i++) |
| 3103 | { |
| 3104 | int j = 0; |
| 3105 | for (auto itex = m_encoderList->begin(); itex != m_encoderList->end(); ++itex) |
| 3106 | { |
| 3107 | cp_s cp_n; |
| 3108 | cp_n.key = itex.key(); |
| 3109 | cp_n.value = (void *) itex.value(); |
| 3110 | if ((cp[j].key != cp_n.key ) || |
| 3111 | (cp[j].value != cp_n.value) ) |
| 3112 | { |
| 3113 | cout << "KdW diff pass " << i << " cp[" << j << "] "; |
| 3114 | cout << "old key,value:" << cp[j].key << " " << cp[j].value << " "; |
| 3115 | cout << "new key,value:" << cp_n.key << " " << cp_n.value << " "; |
| 3116 | cout << "updating" << endl; |
| 3117 | cp[j].key = cp_n.key; |
| 3118 | cp[j].value = cp_n.value; |
| 3119 | } |
| 3120 | j++; |
| 3121 | } |
| 3122 | } |
| 3123 | #endif |
| 3124 | |
| 3125 | // KdW test -- Compare the old values with the current contents after 100ms wait |
| 3126 | // Dit gaat NIET fout (maar met de wachttijd)!! |
| 3127 | #if 0 |
| 3128 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); |
| 3129 | for (int i=0; i<10; i++) |
| 3130 | { |
| 3131 | int j = 0; |
| 3132 | for (auto itex = m_encoderList->begin(); itex != m_encoderList->end(); ++itex) |
| 3133 | { |
| 3134 | cp_s cp_n; |
| 3135 | cp_n.key = itex.key(); |
| 3136 | cp_n.value = (void *) itex.value(); |
| 3137 | if ((cp[j].key != cp_n.key ) || |
| 3138 | (cp[j].value != cp_n.value) ) |
| 3139 | { |
| 3140 | cout << "KdW diff pass " << i << " cp[" << j << "] "; |
| 3141 | cout << "old key,value:" << cp[j].key << " " << cp[j].value << " "; |
| 3142 | cout << "new key,value:" << cp_n.key << " " << cp_n.value << " "; |
| 3143 | cout << "updating" << endl; |
| 3144 | cp[j].key = cp_n.key; |
| 3145 | cp[j].value = cp_n.value; |
| 3146 | } |
| 3147 | j++; |
| 3148 | } |
| 3149 | } |
| 3150 | #endif |
| 3151 | |
| 3152 | // KdW test -- Compare the old values with the current contents without iterator |
| 3153 | // Resultaat: GEEN fouten. Op deze manier de waarde ophalen gaat altijd goed. |
| 3154 | #if 0 |
| 3155 | for (int i=0; i<10000; i++) |
| 3156 | { |
| 3157 | for (int j=0; j<copy_size; j++) |
| 3158 | { |
| 3159 | cp_s cp_n; |
| 3160 | cp_n.key = cp[j].key; |
| 3161 | cp_n.value = m_encoderList->value(cp_n.key, 0); |
| 3162 | if ((cp[j].key != cp_n.key ) || |
| 3163 | (cp[j].value != cp_n.value) ) |
| 3164 | { |
| 3165 | cout << "KdW diff pass " << i << " cp[" << j << "] "; |
| 3166 | cout << "old key,value:" << cp[j].key << " " << cp[j].value << " "; |
| 3167 | cout << "new key,value:" << cp_n.key << " " << cp_n.value << endl; |
| 3168 | } |
| 3169 | } |
| 3170 | } |
| 3171 | #endif |
| 3172 | |