/// <summary> /// tests different hasbits implementations and different filters to perform the same operation /// </summary> public static void TestHasBits() { var records = MockBitArrays.GenerateRandomBitArrays(1000000); var lastRecord = records.Last(); List<IHasBits> hasBitsInt = new List<IHasBits>(); List<IHasBits> hasBitsBoolArray = new List<IHasBits>(); List<IHasBits> hasBitsBitVector = new List<IHasBits>(); List<IHasBits> hasBitsBitArray = new List<IHasBits>(); NaturalIntHasBits last1 = new NaturalIntHasBits(lastRecord); NaturalBoolArrayHasBits last2 = new NaturalBoolArrayHasBits(lastRecord); NaturalBitVectorHasBits last3 = new NaturalBitVectorHasBits(lastRecord); NaturalBitArrayHasBits last4 = new NaturalBitArrayHasBits(lastRecord); records.ForEach(x => { hasBitsInt.Add(new NaturalIntHasBits(x)); hasBitsBoolArray.Add(new NaturalBoolArrayHasBits(x)); hasBitsBitVector.Add(new NaturalBitVectorHasBits(x)); hasBitsBitArray.Add(new NaturalBitArrayHasBits(x)); }); Func<IHasBits, bool> findLastFilter_XOR = (x) => { return x.Bits.AreEquivalent_XORCompare(lastRecord); }; Func<IHasBits, bool> findLastFilter_BitByBit = (x) => { return x.Bits.AreEquivalent_BitByBit(lastRecord); }; Func<IHasBits, bool> findLastFilter_IntCompare = (x) => { return x.Bits.AreEquivalent_IntCompare(lastRecord); }; TestFilterTimes(hasBitsInt, findLastFilter_XOR, "int | XOR"); TestFilterTimes(hasBitsBoolArray, findLastFilter_XOR, "boolarray | XOR"); TestFilterTimes(hasBitsBitVector, findLastFilter_XOR, "bitvector | XOR"); TestFilterTimes(hasBitsBitArray, findLastFilter_XOR, "bitarray | XOR"); TestFilterTimes(hasBitsInt, findLastFilter_BitByBit, "int | bit by bit"); TestFilterTimes(hasBitsBoolArray, findLastFilter_BitByBit, "boolarray | bit by bit"); TestFilterTimes(hasBitsBitVector, findLastFilter_BitByBit, "bitvector | bit by bit"); TestFilterTimes(hasBitsBitArray, findLastFilter_BitByBit, "bitarray | bit by bit"); TestFilterTimes(hasBitsInt, findLastFilter_IntCompare, "int | int compare"); TestFilterTimes(hasBitsBoolArray, findLastFilter_IntCompare, "boolarray | int compare"); TestFilterTimes(hasBitsBitVector, findLastFilter_IntCompare, "bitvector | int compare"); TestFilterTimes(hasBitsBitArray, findLastFilter_IntCompare, "bitarray | int compare"); //apparently bitarray intcompare is the fastest arrangement //now try the AND //Func<IHasBits, bool> findLastFilter_AND = (x) => //{ // var newBits = x.AND(last1); // return newBits.Bits.AreEquivalent_IntCompare(lastRecord); //}; }
/// <summary> /// tests different hasbits implementations and different filters to perform the same operation /// </summary> public static void TestHasBits() { var records = MockBitArrays.GenerateRandomBitArrays(1000000); var lastRecord = records.Last(); List <IHasBits> hasBitsInt = new List <IHasBits>(); List <IHasBits> hasBitsBoolArray = new List <IHasBits>(); List <IHasBits> hasBitsBitVector = new List <IHasBits>(); List <IHasBits> hasBitsBitArray = new List <IHasBits>(); NaturalIntHasBits last1 = new NaturalIntHasBits(lastRecord); NaturalBoolArrayHasBits last2 = new NaturalBoolArrayHasBits(lastRecord); NaturalBitVectorHasBits last3 = new NaturalBitVectorHasBits(lastRecord); NaturalBitArrayHasBits last4 = new NaturalBitArrayHasBits(lastRecord); records.ForEach(x => { hasBitsInt.Add(new NaturalIntHasBits(x)); hasBitsBoolArray.Add(new NaturalBoolArrayHasBits(x)); hasBitsBitVector.Add(new NaturalBitVectorHasBits(x)); hasBitsBitArray.Add(new NaturalBitArrayHasBits(x)); }); Func <IHasBits, bool> findLastFilter_XOR = (x) => { return(x.Bits.AreEquivalent_XORCompare(lastRecord)); }; Func <IHasBits, bool> findLastFilter_BitByBit = (x) => { return(x.Bits.AreEquivalent_BitByBit(lastRecord)); }; Func <IHasBits, bool> findLastFilter_IntCompare = (x) => { return(x.Bits.AreEquivalent_IntCompare(lastRecord)); }; TestFilterTimes(hasBitsInt, findLastFilter_XOR, "int | XOR"); TestFilterTimes(hasBitsBoolArray, findLastFilter_XOR, "boolarray | XOR"); TestFilterTimes(hasBitsBitVector, findLastFilter_XOR, "bitvector | XOR"); TestFilterTimes(hasBitsBitArray, findLastFilter_XOR, "bitarray | XOR"); TestFilterTimes(hasBitsInt, findLastFilter_BitByBit, "int | bit by bit"); TestFilterTimes(hasBitsBoolArray, findLastFilter_BitByBit, "boolarray | bit by bit"); TestFilterTimes(hasBitsBitVector, findLastFilter_BitByBit, "bitvector | bit by bit"); TestFilterTimes(hasBitsBitArray, findLastFilter_BitByBit, "bitarray | bit by bit"); TestFilterTimes(hasBitsInt, findLastFilter_IntCompare, "int | int compare"); TestFilterTimes(hasBitsBoolArray, findLastFilter_IntCompare, "boolarray | int compare"); TestFilterTimes(hasBitsBitVector, findLastFilter_IntCompare, "bitvector | int compare"); TestFilterTimes(hasBitsBitArray, findLastFilter_IntCompare, "bitarray | int compare"); //apparently bitarray intcompare is the fastest arrangement //now try the AND //Func<IHasBits, bool> findLastFilter_AND = (x) => //{ // var newBits = x.AND(last1); // return newBits.Bits.AreEquivalent_IntCompare(lastRecord); //}; }