2.3MB is indeed a bit suprising. I can only imagine there's a lot of
actually unused code pulled in which probably isn't dead-code eliminated
because optimization is off, so first step I would suggest is to try with
optimization, and make sure that dead-code elimination actually works.
There *is* C/C++ runtime overhead of course, but for just std::vector that
shouldn't (hopefully) be as much (e.g. my 'engine hello world' with printf
output is about 617kByte unpacked / 150kByte gzipped).
Personally I'm not using stl containers but have rolled my own (not for
code-bloat reasons, but because I don't want to depend on exceptions).
Cheers,
-Floh.
Am Montag, 21. Juli 2014 11:59:50 UTC+2 schrieb awt:
>
> Hi,
>
> I wrote 2 simple programs to compare the size of the Javascript files
> generated in unoptimized mode for both array and vector:
>
> 1. Array version:
>
> int main()
> {
> int arr1[2000];
> add(arr1);
> return 0;
> }
>
> void add(int arr[])
> {
> for(int i=0;i<2000;i++)
> {
> arr[i]=i;
> }
> }
>
> 2. Vector version:
>
> int main()
> {
> vector<int> v1;
> add(v1);
> return 0;
> }
>
> void add(vector<int>& v)
> {
> for(int i=0;i<2000;i++)
> {
> v.push_back(i);
> }
> }
>
> I was quite surprised that the size of the JS file generated for the array
> is only 203KB but the vector version took up 2393KB. Are there built-in
> optimizations for STL classes in Emscripten that I could leverage on to
> shrink the file size or do I have to implement my own vector classes? Any
> suggestions would be much appreciated. Thanks in advance.
>
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.