Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  sort_basics.js   Sprache: JAVA

 
// Note: failed runs should include their "SEED" value in error messages,
// setting "const SEED" to that value will recreate the data from any such run.
const SEED = (Math.random() * 10) + 1;

// Create an array filled with random values, 'size' is the desired length of
// the array and 'seed' is an initial value supplied to a pseudo-random number
// generator.
function genRandomArray(size, seed) {
    return Array.from(XorShiftGenerator(seed, size));
}

function SortTest(size, seed) {
    let arrOne       = genRandomArray(size, seed);
    let arrTwo       = Array.from(arrOne);
    let arrThree     = Array.from(arrOne);
    let typedArrays  = [
        new Uint8Array(arrOne),
        new Int32Array(arrOne),
        new Float32Array(arrOne)
    ];

    let sorted = Array.from((Int32Array.from(arrOne)).sort());

    // Test numeric comparators against typed array sort.
    assertDeepEq(sorted, arrTwo.sort((x, y) => (x - y)),
                 `The array is not properly sorted! seed: ${SEED}`);

    // Use multiplication to kill comparator optimization and trigger
    // self-hosted sorting.
    assertDeepEq(sorted, arrThree.sort((x, y) => (1*x - 1*y)),
                 `The array is not properly sorted! seed: ${SEED}`);

    // Ensure that typed arrays are also sorted property.
    for (typedArr of typedArrays) {
        let sortedTypedArray = Array.prototype.sort.call(typedArr, (x, y) => (1*x - 1*y))
        assertDeepEq(sorted, Array.from(sortedTypedArray),
                     `The array is not properly sorted! seed: ${SEED}`);
    }
}

SortTest(2048, SEED);
SortTest(16, SEED);
SortTest(0, SEED);

if (typeof reportCompare === "function")
    reportCompare(truetrue);

Messung V0.5
C=93 H=97 G=94

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge