dalerank / imspinner

Set of nice spinners for imgui
MIT License
422 stars 39 forks source link

Compiled library instead of a header-only library #25

Open MortezaAghazamani opened 2 months ago

MortezaAghazamani commented 2 months ago

Hello,

Thank you for creating such fantastic art with the spinners. They are really nice and useful.

I have a question. As the size of the library grows, the compilation time also increases. Are there any plans to make it a compiled library instead of a header-only library?

dalerank commented 2 months ago

I think it not a problem now, full time complation for all samples (230 items) take 75ms, Imgui has compite time much more about 600ms. If sometime it will be more than 200ms can do something, but really it need to have about 700 spinners in library

MortezaAghazamani commented 2 months ago

System specifications: Intel i7-8650U @1.90GHz Visual studio 2022, C++17, x64 release, optimization -O2 ImGui static lib compiled by VCPKG.

I did not include this part of report as they are quite similar in all my tests. 1> 0 ms ConvertToAbsolutePath 1 calls 1> 0 ms SetEnv 9 calls 1> 0 ms Delete 6 calls 1> 0 ms RemoveDuplicates 3 calls 1> 0 ms MakeDir 12 calls 1> 0 ms AssignProjectConfiguration 1 calls 1> 0 ms MSBuild 1 calls 1> 0 ms CheckVCToolsetVersion 1 calls 1> 0 ms Touch 2 calls 1> 0 ms GetOutOfDateItems 3 calls 1> 0 ms GenerateDesktopDeployRecipe 1 calls 1> 0 ms AssignCulture 1 calls 1> 1 ms FindUnderPath 7 calls 1> 1 ms WriteLinesToFile 3 calls 1> 1 ms ReadLinesFromFile 4 calls 1> 1 ms CallTarget 2 calls 1> 2 ms Message 8 calls 1> 2 ms CppClean 1 calls 1> 2 ms AssignTargetPath 7 calls




#include <imgui.h>
#include "imspinner.h"
#include "a.h"
#include "b.h"

void main()
{
  ImGui::Begin("");
  ImSpinner::SpinnerArcFade("test", 1.f, 1.f);
  testA();
  testB();
}

1> 355 ms Exec 2 calls 1> 368 ms Link 1 calls 1> ${\color{red}2470 ms}$ CL 1 calls

a.h: (b files are Same as a files, only the function name is different)

#pragma once
void testA();

a.cpp:

#include "a.h"
#include <imgui.h>
#include "imspinner.h"
void testA()
{
    ImGui::Begin("");
    ImSpinner::SpinnerArcFade("test", 1.f, 1.f);
}

I only had to compile ImGui once and I could use it multiple times without needing to make any changes inside the library. Therefore, I didn't track the compile time for ImGui. I was hoping for the same efficiency with imspinner, but that wasn't the case. This is because when using a header-only library, the compiler has to recompile every file that uses it if I make any changes in that file.

The compilation time on my system has increased significantly. However having a powerful system reduces the compilation time, but optimizing for both time and power efficiency is valuable.

dalerank commented 2 months ago

It strange, will look why it happens. But you also can suggest a solution if found to faster then me