Javascript的ES6 class写法和ES5闭包写法性能对比

news2024/11/15 23:48:51

看到很多闭包写法的函数, 
一直怀疑它对性能是否有影响.
还有就是备受推崇的React Hooks函数式写法中出现大量的闭包和临时函数,
我很担心这样会影响性能.

于是, 做了一个实验来做对比.
这个实验很简单, 用md5计算一百万次.

计算过程将结果再放回参数, 这样避免结果没被引用被优化, 影响对比结果.
其中test.js采用闭包写法, test2.js采用class写法.
最终的对比结果如下图所示.
闭包的写法略差于class写法, 大概20%
因此对性能要求比较高的话, 还是推荐class写法.  


下面是闭包写法test.js的代码

function md5 (string) {
    function rotateLeft(lValue, iShiftBits) {
        return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
    }
    function addUnsigned(lX, lY) {
        let lX8 = lX & 0x80000000;
        let lY8 = lY & 0x80000000;
        let lX4 = lX & 0x40000000;
        let lY4 = lY & 0x40000000;
        let lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);
        if (lX4 & lY4) {
            return lResult ^ 0x80000000 ^ lX8 ^ lY8;
        }
    
        if (lX4 | lY4) {
            if (lResult & 0x40000000) {
                return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
            } else {
                return lResult ^ 0x40000000 ^ lX8 ^ lY8;
            }
        } else {
            return lResult ^ lX8 ^ lY8;
        }
    }
    function F(x, y, z) {
        return (x & y) | (~x & z);
    }
    function G(x, y, z) {
        return (x & z) | (y & ~z);
    }
    function H(x, y, z) {
        return x ^ y ^ z;
    }
    function I(x, y, z) {
        return y ^ (x | ~z);
    }
    function FF(a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(F(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
    }
    function GG(a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(G(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
    }
    function HH(a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(H(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
    }
    function II(a, b, c, d, x, s, ac) {
        a = addUnsigned(a, addUnsigned(addUnsigned(I(b, c, d), x), ac));
        return addUnsigned(rotateLeft(a, s), b);
    }
    function convertToWordArray(string) {
        let lWordCount;
        let lMessageLength = string.length;
        let lNumberOfWordsTempOne = lMessageLength + 8;
        let lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64;
        let lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
        let lWordArray = Array(lNumberOfWords - 1);
        let lBytePosition = 0;
        let lByteCount = 0;
        while (lByteCount < lMessageLength) {
            lWordCount = (lByteCount - (lByteCount % 4)) / 4;
            lBytePosition = (lByteCount % 4) * 8;
            lWordArray[lWordCount] =
                lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition);
            lByteCount++;
        }
        lWordCount = (lByteCount - (lByteCount % 4)) / 4;
        lBytePosition = (lByteCount % 4) * 8;
        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
        lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
        lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
        return lWordArray;
    }
    function wordToHex(lValue) {
        let WordToHexValue = "";
        let WordToHexValueTemp = "";
        let lByte;
        for (let lCount = 0; lCount <= 3; lCount++) {
            lByte = (lValue >>> (lCount * 8)) & 255;
            WordToHexValueTemp = "0" + lByte.toString(16);
            WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
        }
        return WordToHexValue;
    }
    function uTF8Encode(string) {
        string = string.replace(/\x0d\x0a/g, "\x0a");
        let output = "";
        for (let n = 0; n < string.length; n++) {
            let c = string.charCodeAt(n);
            if (c < 128) {
                output += String.fromCharCode(c);
            } else if (c > 127 && c < 2048) {
                output += String.fromCharCode((c >> 6) | 192);
                output += String.fromCharCode((c & 63) | 128);
            } else {
                output += String.fromCharCode((c >> 12) | 224);
                output += String.fromCharCode(((c >> 6) & 63) | 128);
                output += String.fromCharCode((c & 63) | 128);
            }
        }
        return output;
    }
    function res(string) {
        let x = [];
        let AA, BB, CC, DD;
        let S11 = 7;
        let S12 = 12;
        let S13 = 17;
        let S14 = 22;
        let S21 = 5;
        let S22 = 9;
        let S23 = 14;
        let S24 = 20;
        let S31 = 4;
        let S32 = 11;
        let S33 = 16;
        let S34 = 23;
        let S41 = 6;
        let S42 = 10;
        let S43 = 15;
        let S44 = 21;
        string = uTF8Encode(string);
        x = convertToWordArray(string);
        let a = 0x67452301;
        let b = 0xefcdab89;
        let c = 0x98badcfe;
        let d = 0x10325476;
        for (let k = 0; k < x.length; k += 16) {
            AA = a;
            BB = b;
            CC = c;
            DD = d;
            a = FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
            d = FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
            c = FF(c, d, a, b, x[k + 2], S13, 0x242070db);
            b = FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
            a = FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
            d = FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
            c = FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
            b = FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
            a = FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
            d = FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
            c = FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
            b = FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
            a = FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
            d = FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
            c = FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
            b = FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
            a = GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
            d = GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
            c = GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
            b = GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
            a = GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
            d = GG(d, a, b, c, x[k + 10], S22, 0x2441453);
            c = GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
            b = GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
            a = GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
            d = GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
            c = GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
            b = GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
            a = GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
            d = GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
            c = GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
            b = GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
            a = HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
            d = HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
            c = HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
            b = HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
            a = HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
            d = HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
            c = HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
            b = HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
            a = HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
            d = HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
            c = HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
            b = HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
            a = HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
            d = HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
            c = HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
            b = HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
            a = II(a, b, c, d, x[k + 0], S41, 0xf4292244);
            d = II(d, a, b, c, x[k + 7], S42, 0x432aff97);
            c = II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
            b = II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
            a = II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
            d = II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
            c = II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
            b = II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
            a = II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
            d = II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
            c = II(c, d, a, b, x[k + 6], S43, 0xa3014314);
            b = II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
            a = II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
            d = II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
            c = II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
            b = II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
            a = addUnsigned(a, AA);
            b = addUnsigned(b, BB);
            c = addUnsigned(c, CC);
            d = addUnsigned(d, DD);
        }
        let tempValue = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
        return tempValue.toLowerCase();
    }
    return res(string);
}

function testMd5() {
    let startTick = Date.now() / 1000;
    let result = "测试文本字符串测试文本字符串测试文本字符串";
    for (let i = 0; i< 1e6; ++i) {
        result = md5(result+i);
    }
    console.log(result);
    let endTick = Date.now() / 1000; 
    console.log(endTick - startTick);
}

testMd5();

 下面是类写法test2.js的代码.

class Md5Class {
    rotateLeft(lValue, iShiftBits) {
        return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
    }
    addUnsigned(lX, lY) {
        let lX8 = lX & 0x80000000;
        let lY8 = lY & 0x80000000;
        let lX4 = lX & 0x40000000;
        let lY4 = lY & 0x40000000;
        let lResult = (lX & 0x3fffffff) + (lY & 0x3fffffff);
        if (lX4 & lY4) {
            return lResult ^ 0x80000000 ^ lX8 ^ lY8;
        }
    
        if (lX4 | lY4) {
            if (lResult & 0x40000000) {
                return lResult ^ 0xc0000000 ^ lX8 ^ lY8;
            } else {
                return lResult ^ 0x40000000 ^ lX8 ^ lY8;
            }
        } else {
            return lResult ^ lX8 ^ lY8;
        }
    }
    F(x, y, z) {
        return (x & y) | (~x & z);
    }
    G(x, y, z) {
        return (x & z) | (y & ~z);
    }
    H(x, y, z) {
        return x ^ y ^ z;
    }
    I(x, y, z) {
        return y ^ (x | ~z);
    }
    FF(a, b, c, d, x, s, ac) {
        a = this.addUnsigned(a, this.addUnsigned(this.addUnsigned(this.F(b, c, d), x), ac));
        return this.addUnsigned(this.rotateLeft(a, s), b);
    }
    GG(a, b, c, d, x, s, ac) {
        a = this.addUnsigned(a, this.addUnsigned(this.addUnsigned(this.G(b, c, d), x), ac));
        return this.addUnsigned(this.rotateLeft(a, s), b);
    }
    HH(a, b, c, d, x, s, ac) {
        a = this.addUnsigned(a, this.addUnsigned(this.addUnsigned(this.H(b, c, d), x), ac));
        return this.addUnsigned(this.rotateLeft(a, s), b);
    }
    II(a, b, c, d, x, s, ac) {
        a = this.addUnsigned(a, this.addUnsigned(this.addUnsigned(this.I(b, c, d), x), ac));
        return this.addUnsigned(this.rotateLeft(a, s), b);
    }
    convertToWordArray(string) {
        let lWordCount;
        let lMessageLength = string.length;
        let lNumberOfWordsTempOne = lMessageLength + 8;
        let lNumberOfWordsTempTwo = (lNumberOfWordsTempOne - (lNumberOfWordsTempOne % 64)) / 64;
        let lNumberOfWords = (lNumberOfWordsTempTwo + 1) * 16;
        let lWordArray = Array(lNumberOfWords - 1);
        let lBytePosition = 0;
        let lByteCount = 0;
        while (lByteCount < lMessageLength) {
            lWordCount = (lByteCount - (lByteCount % 4)) / 4;
            lBytePosition = (lByteCount % 4) * 8;
            lWordArray[lWordCount] =
                lWordArray[lWordCount] | (string.charCodeAt(lByteCount) << lBytePosition);
            lByteCount++;
        }
        lWordCount = (lByteCount - (lByteCount % 4)) / 4;
        lBytePosition = (lByteCount % 4) * 8;
        lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80 << lBytePosition);
        lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
        lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
        return lWordArray;
    }
    wordToHex(lValue) {
        let WordToHexValue = "";
        let WordToHexValueTemp = "";
        let lByte;
        for (let lCount = 0; lCount <= 3; lCount++) {
            lByte = (lValue >>> (lCount * 8)) & 255;
            WordToHexValueTemp = "0" + lByte.toString(16);
            WordToHexValue = WordToHexValue + WordToHexValueTemp.substr(WordToHexValueTemp.length - 2, 2);
        }
        return WordToHexValue;
    }
    uTF8Encode(string) {
        string = string.replace(/\x0d\x0a/g, "\x0a");
        let output = "";
        for (let n = 0; n < string.length; n++) {
            let c = string.charCodeAt(n);
            if (c < 128) {
                output += String.fromCharCode(c);
            } else if (c > 127 && c < 2048) {
                output += String.fromCharCode((c >> 6) | 192);
                output += String.fromCharCode((c & 63) | 128);
            } else {
                output += String.fromCharCode((c >> 12) | 224);
                output += String.fromCharCode(((c >> 6) & 63) | 128);
                output += String.fromCharCode((c & 63) | 128);
            }
        }
        return output;
    }
    res(string) {
        let x = [];
        let AA, BB, CC, DD;
        let S11 = 7;
        let S12 = 12;
        let S13 = 17;
        let S14 = 22;
        let S21 = 5;
        let S22 = 9;
        let S23 = 14;
        let S24 = 20;
        let S31 = 4;
        let S32 = 11;
        let S33 = 16;
        let S34 = 23;
        let S41 = 6;
        let S42 = 10;
        let S43 = 15;
        let S44 = 21;
        string = this.uTF8Encode(string);
        x = this.convertToWordArray(string);
        let a = 0x67452301;
        let b = 0xefcdab89;
        let c = 0x98badcfe;
        let d = 0x10325476;
        for (let k = 0; k < x.length; k += 16) {
            AA = a;
            BB = b;
            CC = c;
            DD = d;
            a = this.FF(a, b, c, d, x[k + 0], S11, 0xd76aa478);
            d = this.FF(d, a, b, c, x[k + 1], S12, 0xe8c7b756);
            c = this.FF(c, d, a, b, x[k + 2], S13, 0x242070db);
            b = this.FF(b, c, d, a, x[k + 3], S14, 0xc1bdceee);
            a = this.FF(a, b, c, d, x[k + 4], S11, 0xf57c0faf);
            d = this.FF(d, a, b, c, x[k + 5], S12, 0x4787c62a);
            c = this.FF(c, d, a, b, x[k + 6], S13, 0xa8304613);
            b = this.FF(b, c, d, a, x[k + 7], S14, 0xfd469501);
            a = this.FF(a, b, c, d, x[k + 8], S11, 0x698098d8);
            d = this.FF(d, a, b, c, x[k + 9], S12, 0x8b44f7af);
            c = this.FF(c, d, a, b, x[k + 10], S13, 0xffff5bb1);
            b = this.FF(b, c, d, a, x[k + 11], S14, 0x895cd7be);
            a = this.FF(a, b, c, d, x[k + 12], S11, 0x6b901122);
            d = this.FF(d, a, b, c, x[k + 13], S12, 0xfd987193);
            c = this.FF(c, d, a, b, x[k + 14], S13, 0xa679438e);
            b = this.FF(b, c, d, a, x[k + 15], S14, 0x49b40821);
            a = this.GG(a, b, c, d, x[k + 1], S21, 0xf61e2562);
            d = this.GG(d, a, b, c, x[k + 6], S22, 0xc040b340);
            c = this.GG(c, d, a, b, x[k + 11], S23, 0x265e5a51);
            b = this.GG(b, c, d, a, x[k + 0], S24, 0xe9b6c7aa);
            a = this.GG(a, b, c, d, x[k + 5], S21, 0xd62f105d);
            d = this.GG(d, a, b, c, x[k + 10], S22, 0x2441453);
            c = this.GG(c, d, a, b, x[k + 15], S23, 0xd8a1e681);
            b = this.GG(b, c, d, a, x[k + 4], S24, 0xe7d3fbc8);
            a = this.GG(a, b, c, d, x[k + 9], S21, 0x21e1cde6);
            d = this.GG(d, a, b, c, x[k + 14], S22, 0xc33707d6);
            c = this.GG(c, d, a, b, x[k + 3], S23, 0xf4d50d87);
            b = this.GG(b, c, d, a, x[k + 8], S24, 0x455a14ed);
            a = this.GG(a, b, c, d, x[k + 13], S21, 0xa9e3e905);
            d = this.GG(d, a, b, c, x[k + 2], S22, 0xfcefa3f8);
            c = this.GG(c, d, a, b, x[k + 7], S23, 0x676f02d9);
            b = this.GG(b, c, d, a, x[k + 12], S24, 0x8d2a4c8a);
            a = this.HH(a, b, c, d, x[k + 5], S31, 0xfffa3942);
            d = this.HH(d, a, b, c, x[k + 8], S32, 0x8771f681);
            c = this.HH(c, d, a, b, x[k + 11], S33, 0x6d9d6122);
            b = this.HH(b, c, d, a, x[k + 14], S34, 0xfde5380c);
            a = this.HH(a, b, c, d, x[k + 1], S31, 0xa4beea44);
            d = this.HH(d, a, b, c, x[k + 4], S32, 0x4bdecfa9);
            c = this.HH(c, d, a, b, x[k + 7], S33, 0xf6bb4b60);
            b = this.HH(b, c, d, a, x[k + 10], S34, 0xbebfbc70);
            a = this.HH(a, b, c, d, x[k + 13], S31, 0x289b7ec6);
            d = this.HH(d, a, b, c, x[k + 0], S32, 0xeaa127fa);
            c = this.HH(c, d, a, b, x[k + 3], S33, 0xd4ef3085);
            b = this.HH(b, c, d, a, x[k + 6], S34, 0x4881d05);
            a = this.HH(a, b, c, d, x[k + 9], S31, 0xd9d4d039);
            d = this.HH(d, a, b, c, x[k + 12], S32, 0xe6db99e5);
            c = this.HH(c, d, a, b, x[k + 15], S33, 0x1fa27cf8);
            b = this.HH(b, c, d, a, x[k + 2], S34, 0xc4ac5665);
            a = this.II(a, b, c, d, x[k + 0], S41, 0xf4292244);
            d = this.II(d, a, b, c, x[k + 7], S42, 0x432aff97);
            c = this.II(c, d, a, b, x[k + 14], S43, 0xab9423a7);
            b = this.II(b, c, d, a, x[k + 5], S44, 0xfc93a039);
            a = this.II(a, b, c, d, x[k + 12], S41, 0x655b59c3);
            d = this.II(d, a, b, c, x[k + 3], S42, 0x8f0ccc92);
            c = this.II(c, d, a, b, x[k + 10], S43, 0xffeff47d);
            b = this.II(b, c, d, a, x[k + 1], S44, 0x85845dd1);
            a = this.II(a, b, c, d, x[k + 8], S41, 0x6fa87e4f);
            d = this.II(d, a, b, c, x[k + 15], S42, 0xfe2ce6e0);
            c = this.II(c, d, a, b, x[k + 6], S43, 0xa3014314);
            b = this.II(b, c, d, a, x[k + 13], S44, 0x4e0811a1);
            a = this.II(a, b, c, d, x[k + 4], S41, 0xf7537e82);
            d = this.II(d, a, b, c, x[k + 11], S42, 0xbd3af235);
            c = this.II(c, d, a, b, x[k + 2], S43, 0x2ad7d2bb);
            b = this.II(b, c, d, a, x[k + 9], S44, 0xeb86d391);
            a = this.addUnsigned(a, AA);
            b = this.addUnsigned(b, BB);
            c = this.addUnsigned(c, CC);
            d = this.addUnsigned(d, DD);
        }
        let tempValue = this.wordToHex(a) + this.wordToHex(b) + this.wordToHex(c) + this.wordToHex(d);
        return tempValue.toLowerCase();
    }
}
let md5 = new Md5Class();

function testMd5() {
    let startTick = Date.now() / 1000;
    let result = "测试文本字符串测试文本字符串测试文本字符串";
    for (let i = 0; i< 1e6; ++i) {
        result = md5.res(result+i);
    }
    console.log(result);
    let endTick = Date.now() / 1000; 
    console.log(endTick - startTick);
}

testMd5();

还有就是对于React Hooks写法, 个人感觉,
会导致代码更凌乱, 结构层次不清晰, 可读性和可维护性下降.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/400757.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Git 学习(三)—— 本地仓库 — 远程仓库的操作命令

为了可以让其他用户看到自己的成果&#xff0c;我们可以将自己本地仓库的内容上传到远程仓库&#xff1b;如果我们希望借鉴其他用户的成果&#xff0c;我们可以将远程仓库里的一些内容拉取或者克隆到本地仓库。 这里先暂不考虑 本地到远程 或者 远程到本地 的一些相关操作&…

避坑指南—GPL开源协议

0x00 前言 本文主要目的是为了了解一些基础的GPL注意事项&#xff0c;以及防止被一些一知半解的人蒙骗。本文不做任何内容的依据&#xff0c;仅为个人见解&#xff0c;仅供参考。 一些常见的开源协议 GPLBSDMITMozillaApacheLGPL 0x01 GPL GPL许可协议(GNU General Public …

知识点——域适应、域泛化、在线测试适应区别 DA、DG、TTA区别

文章目录1.Domain Adaptation( DA&#xff1a;域适应 )源域和目标域&#xff1a;DA研究问题&#xff1a;DA目标&#xff1a;DA主要思想&#xff1a;DA三种方法&#xff1a;2.Domain generalization( DG&#xff1a;域泛化 )DG研究问题&#xff1a;DG目标&#xff1a;DA和DG优点…

css——图片缩放,拉伸,变形的解决办法

你的图片即将变得超级丝滑图片为什么会拉伸变形&#xff1f;怎么解决&#xff1f;css的object-fit属性object-fit属性有什么用介绍一下object-position举个小栗子图片为什么会拉伸变形&#xff1f; 前端布局时&#xff0c;图片会出现拉伸、缩放和变形的原因可能有多种: 1.例如图…

2.3操作系统-存储管理:页式存储、逻辑地址、物理地址、物理地址逻辑地址之间的地址关系、页面大小与页内地址长度的关系、缺页中断、内存淘汰规则

2.3操作系统-存储管理&#xff1a;页式存储、逻辑地址、物理地址、物理地址逻辑地址之间的地址关系、页面大小与页内地址长度的关系、缺页中断、内存淘汰规则页式存储逻辑地址、物理地址如何判断物理地址和逻辑地址它们之间的地址关系&#xff1f;页面大小与页内地址长度的关系…

现货交易入门之垂死挣扎

本文讲解的也是挣扎形态&#xff0c;前面以已经讲过一个挣扎形态&#xff0c;但是本文这个形态的名字更让人能耳目一新&#xff0c;因为它叫“垂死挣扎线”&#xff0c;这并不是普通的挣扎线。是“垂死”的&#xff01; “垂死挣扎线”与“顶部挣扎线”很相似&#xff0c;都是出…

JavaApi操作ElasticSearch(强烈推荐)

ElasticSearch 高级 1 javaApi操作es环境搭建 在elasticsearch官网中提供了各种语言的客户端&#xff1a;https://www.elastic.co/guide/en/elasticsearch/client/index.html 而Java的客户端就有两个&#xff1a; 不过Java API这个客户端&#xff08;Transport Client&#…

element-ui日期选择器时间差

关于使用element-ui日期选择器时&#xff0c;发现时间差问题&#xff0c;特此记录下 #主要记录三个问题 日期选择器选择时获取到的格式相差八小时当日期格式为–拼接时&#xff0c;转成时间戳会相差八小时&#xff08;2023-03-09&#xff09;DatePicker设置区域范围和校验&…

TiDB数据库架构概述

文章目录TiDB体系架构TiDB ServerStorage Cluster(存储引擎)PD cluster题目TiDB体系架构 TiDB Server Sql语句最先到达 TiDB Server集群 它是无状态的&#xff0c;数据并不是存储在这里面&#xff0c;当一个会话连接到TiDB Server集群上&#xff0c;sql语句发过来&#xff0c…

大数据自学学习技巧?

经常有人说&#xff1a;先别管大数据是什么&#xff0c;现在理解不了没关系&#xff0c;先开始学&#xff0c;等学着学着就明白了&#xff0c;这种学习路线基本是混合的&#xff0c;很难分清楚自己学了这段怎么用在以后项目中&#xff0c;所以会越学越迷茫&#xff0c;但是等你…

机房漏水设备受损,一招轻松避免

随着科学信息技术的发展和社会经济的快速发展,计算机系统得到了广泛的应用&#xff0c;计算机房设备中使用的设备越来越多。 漏水对机房内精密电子设备容易造成损坏&#xff0c;电器短路等。一旦机房发生漏液&#xff0c;水流到线槽&#xff0c;会导致机房断电&#xff0c;造成…

IPv6公共DNS现在提供加密DNS查询

支持DoT/DoH DoT:dns.ipv6dns.comDoH:https://dns.ipv6dns.com/dns-query为什么需要加密DNS 配置: Windows 10/8/7 1 右键网络进入属性或者右键右下角的Inernet进入网络共享中心,如下图: 2 点击网络和共享中心左侧的"更改适配器设置"链接,如下图: 3 选中正…

一文读懂pinia Vue状态管理

文章目录1.概述&#xff1a;2. 准备工作3.pinia 安装及使用3.1. 安装pinia3.2 store的创建和使用3.3 getters 使用3.4 action 的使用3.5 总结示例代码4.总结1.概述&#xff1a; pinia 类似与vue2 中的vuex &#xff0c;实现跨页面共享状态管理&#xff0c;类似与java 中的sess…

Git设置SSH Key

一、git 配置 &#xff08;1&#xff09;打开 git 命令窗口 &#xff08;2&#xff09;配置用户名&#xff08;填自己的姓名&#xff09; git config --global user.name “xinyu.xia” &#xff08;3&#xff09;配置用户邮箱&#xff08;填自己的邮箱&#xff0…

在SNAP中用sentinel-1数据做DInSAR测量---以门源地震为例

在SNAP中用sentinel-1数据做DInSAR测量---以门源地震为例0 写在前面1 数据下载2 处理步骤2.1 split2.2 apply orbit 导入精密轨道2.3 查看数据的时空基线base line2.4 back-geocoding 配准2.5 Enhanced Spectral Diversity2.6 Deburst2.7 Interogram Formation 生成干涉图2.8 M…

【Unity3D日常开发】Unity3D中协程的使用

推荐阅读 CSDN主页GitHub开源地址Unity3D插件分享简书地址我的个人博客 大家好&#xff0c;我是佛系工程师☆恬静的小魔龙☆&#xff0c;不定时更新Unity开发技巧&#xff0c;觉得有用记得一键三连哦。 一、前言 最近有小伙伴问协程怎么用、怎么写&#xff0c;我也是会用会写…

Revit管理链接模型视图样式和链接CAD

一、Revit中如何管理链接模型的视图样式 Revit软件协同&#xff0c;无非就两种方式&#xff1a;1、工作集;2、链接文件。其中“工作集”属于软件内部的工作协调方式&#xff0c;不是我们本期问题汇总要说明的问题&#xff0c;这里我们着重说一下第二种关于“链接文件”方式协同…

我们的理性何处安放

每天工作压力和各种人相处都让我们非常忙碌&#xff0c;我们上大学&#xff0c;努力工作&#xff0c;都是想获得更好的人生场景&#xff0c;素养&#xff0c;提升自身的认知&#xff0c;这样就是对我们大多数人生最负责任。如何让自己理性与人为善&#xff0c;并能被人温柔以待…

大数据-学习实践-3HDFS

大数据-学习实践-2HDFS (大数据系列) 文章目录大数据-学习实践-2HDFS1知识点2具体内容2.1HDFS介绍2.2HDFS操作2.2.1基本操作2.2.2Java操作HDFS2.3HDFS体系结构2.3.1NameNode2.3.2SecondaryNameNode2.3.3DataNode2.3.4总结2.4HDFS回收站2.4HDFS安全模式2.5定时上传至HDFS2.6HDF…

java版工程项目管理系统 Spring Cloud+Spring Boot+Mybatis+Vue+ElementUI+前后端分离 功能清单

java版工程项目管理系统 Spring CloudSpring BootMybatisVueElementUI前后端分离 功能清单如下&#xff1a; 首页 工作台&#xff1a;待办工作、消息通知、预警信息&#xff0c;点击可进入相应的列表 项目进度图表&#xff1a;选择&#xff08;总体或单个&#xff09;项目显…