Skip to content

Commit

Permalink
Remove logging
Browse files Browse the repository at this point in the history
  • Loading branch information
lukastaegert committed Feb 3, 2023
1 parent b1c586f commit 8847d3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 72 deletions.
17 changes: 17 additions & 0 deletions browser/LICENSE.md
Expand Up @@ -226,3 +226,20 @@ Repository: https://github.com/calvinmetcalf/minimalistic-assert.git
> LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
> OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
> PERFORMANCE OF THIS SOFTWARE.
---------------------------------------

## pretty-bytes
License: MIT
By: Sindre Sorhus
Repository: sindresorhus/pretty-bytes

> MIT License
>
> Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
>
> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73 changes: 1 addition & 72 deletions src/utils/chunkAssignment.ts
@@ -1,4 +1,3 @@
import prettyBytes from 'pretty-bytes';
import ExternalModule from '../ExternalModule';
import Module from '../Module';
import { getNewSet, getOrCreate } from './getOrCreate';
Expand Down Expand Up @@ -272,67 +271,30 @@ function getOptimizedChunks(
) {
timeStart('optimize chunks', 3);
const chunkPartition = getPartitionedChunks(chunkModulesBySignature, minChunkSize);
console.log(`Created ${
chunkPartition.big.pure.size +
chunkPartition.big.sideEffect.size +
chunkPartition.small.pure.size +
chunkPartition.small.sideEffect.size
} chunks
----- pure side effects
small ${`${chunkPartition.small.pure.size}`.padEnd(5, ' ')} ${chunkPartition.small.sideEffect.size}
big ${`${chunkPartition.big.pure.size}`.padEnd(5, ' ')} ${chunkPartition.big.sideEffect.size}
Unoptimized chunks contain ${getNumberOfCycles(chunkPartition)} cycles.
`);

if (chunkPartition.small.sideEffect.size > 0) {
console.log(
`Trying to find merge targets for ${
chunkPartition.small.sideEffect.size
} chunks smaller than ${prettyBytes(minChunkSize)} with side effects...`
);
mergeChunks(
chunkPartition.small.sideEffect,
[chunkPartition.small.pure, chunkPartition.big.pure],
minChunkSize,
chunkPartition
);
console.log(
`${chunkPartition.small.sideEffect.size} chunks smaller than ${prettyBytes(
minChunkSize
)} with side effects remaining.\nGenerated chunks contain ${getNumberOfCycles(
chunkPartition
)} cycles.\n`
);
}

if (chunkPartition.small.pure.size > 0) {
console.log(
`Trying to find merge targets for ${
chunkPartition.small.pure.size
} pure chunks smaller than ${prettyBytes(minChunkSize)}...`
);
mergeChunks(
chunkPartition.small.pure,
[chunkPartition.small.pure, chunkPartition.big.sideEffect, chunkPartition.big.pure],
minChunkSize,
chunkPartition
);

console.log(
`${chunkPartition.small.pure.size} pure chunks smaller than ${prettyBytes(
minChunkSize
)} remaining.\nGenerated chunks contain ${getNumberOfCycles(chunkPartition)} cycles.\n`
);
}
timeEnd('optimize chunks', 3);
const result = [
return [
...chunkPartition.small.sideEffect,
...chunkPartition.small.pure,
...chunkPartition.big.sideEffect,
...chunkPartition.big.pure
];
console.log(`${result.length} chunks remaining.`);
return result;
}

const CHAR_DEPENDENT = 'X';
Expand Down Expand Up @@ -387,39 +349,6 @@ function getPartitionedChunks(
};
}

function getNumberOfCycles(partition: ChunkPartition) {
const parents = new Set<ChunkDescription>();
const analysedChunks = new Set<ChunkDescription>();
let cycles = 0;

const analyseChunk = (chunk: ChunkDescription) => {
for (const dependency of chunk.dependencies) {
if (parents.has(dependency)) {
if (!analysedChunks.has(dependency)) {
cycles++;
}
continue;
}
parents.add(dependency);
analyseChunk(dependency);
}
analysedChunks.add(chunk);
};

for (const chunk of [
...partition.big.pure,
...partition.big.sideEffect,
...partition.small.pure,
...partition.small.sideEffect
]) {
if (!parents.has(chunk)) {
parents.add(chunk);
analyseChunk(chunk);
}
}
return cycles;
}

function sortChunksAndAddDependencies(
chunkLists: ChunkDescription[][],
chunkByModule: Map<Module, ChunkDescription>
Expand Down

0 comments on commit 8847d3a

Please sign in to comment.