# Tunning loop performance!

**URL:** <https://community.thunkable.com/t/tunning-loop-performance/556725>\
**Category:** Questions about Thunkable X\
**Tags:** beginner\
**Created:** [April 5, 2020, 6:40am UTC](https://community.thunkable.com/t/tunning-loop-performance/556725 "2020-04-05T06:40:42Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![anhtn0711oy](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@anhtn0711oy](https://community.thunkable.com/u/anhtn0711oy)\
**Post date:** [April 5, 2020, 6:40am UTC](https://community.thunkable.com/t/tunning-loop-performance/556725/1 "2020-04-05T06:40:42Z")

</div>

Hi bros, i created very simple app to calculate something.  
The logic is:  
Input a number. Input a date.  
From inputed nunber, convert to new number by \*80%.  
For the date, i compare between current date and inputed date to have number of different days.  
After having those input parrameters, the calculation to reduce the number day by day with the formular number \* ratio; ratio = 0.002 or 0.001 depends on how many different days between inputed date and current date.  
My app working well with thunkable live. But on my iphone, It runs but doesn’t work, some attempts to click button then it unstable works but the return result is not correct as live.  
so anyway to tunning, could you see my app in zip attachment file and advice me please.  
[Desktop.zip](https://community.thunkable.com/uploads/short-url/pBVqvgfnZERjGXfpDUMLbPBZalS.zip) (863.3 KB)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 5, 2020, 1:09pm UTC](https://community.thunkable.com/t/tunning-loop-performance/556725/2 "2020-04-05T13:09:27Z")

</div>

Hi @anhtn0711oy, thanks for posting and welcome to the community! 👋

One request. instead of an apk, can you provide a share link to the project?

---

<div class="post-metadata">

**Author:** ![anhtn0711oy](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@anhtn0711oy](https://community.thunkable.com/u/anhtn0711oy)\
**Post date:** [April 5, 2020, 4:07pm UTC](https://community.thunkable.com/t/tunning-loop-performance/556725/3 "2020-04-05T16:07:09Z")

</div>

Thanks Jared.  
i found the reason is because of a large loop.  
i tried to do very simple one and cannot run on iphone.  
[https://x.thunkable.com/projects/5e89f2b4beea2730c4d95fab/e5b284ff-d1d3-4f67-bf7e-f7dadb44ad75/blocks](https://x.thunkable.com/projects/5e89f2b4beea2730c4d95fab/e5b284ff-d1d3-4f67-bf7e-f7dadb44ad75/blocks)  
So with a project having large loop, is there another better way to do instead of using repeat while i \> 20.000 do xxx

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 5, 2020, 4:14pm UTC](https://community.thunkable.com/t/tunning-loop-performance/556725/4 "2020-04-05T16:14:01Z")

</div>

> [@anhtn0711oy](#):
>
> having large loop, is there another better way to do instead of using repeat while i \> 20.000 do xxx

Potentially, @anhtn0711oy, I’ll check out your app sometime today/tomorrow and get back to you. There are others on here who are great with code optimization as well, maybe they will provide some input also! 🙂 i run some pretty big functions without slowing down my app. it depends on how it is called and looped i suppose.

---

<div class="post-metadata">

**Author:** ![anhtn0711oy](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@anhtn0711oy](https://community.thunkable.com/u/anhtn0711oy)\
**Post date:** [April 5, 2020, 11:45pm UTC](https://community.thunkable.com/t/tunning-loop-performance/556725/5 "2020-04-05T23:45:20Z")

</div>

Thanks so much Jared to spend time for me.  
even i do not put any formula inside the loop, just increasing the loop element i,  
it also makes the app very slow and cannot response the result on mobile device, on computer thunkable live, it’s running well, just need 2 second then response the result.  
here is very simple blocks simulating the loop

 ![loop](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/f/6f53cc04dd4e7ba6126c8a7ad411ddc7b7295353.png)

---

<div class="post-metadata">

**Author:** ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)\
**Post date:** [April 5, 2020, 11:52pm UTC](https://community.thunkable.com/t/tunning-loop-performance/556725/6 "2020-04-05T23:52:00Z")

</div>

Well. I mean. You put everything on hold to count to 15,000. Depending on the device, that may take a long time. It was about 1/2 second or less using an iPhone 11. It was almost instant when I executed the code using the method below

Also, when you use an app type variable, the speed is slower than that of a function type variable due to thunkable architecture.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/8/8/8886284a5e8d74863d12f65770d2d46080ec183e.jpeg)  
See my example  
[https://thunk.app/w/UV\_Uld0mi](https://thunk.app/w/UV_Uld0mi)

Remix my example  
[https://x.thunkable.com/copy/93fcbdd7458d93b91252a6de91353039](https://x.thunkable.com/copy/93fcbdd7458d93b91252a6de91353039)

---

<div class="post-metadata">

**Author:** ![anhtn0711oy](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@anhtn0711oy](https://community.thunkable.com/u/anhtn0711oy)\
**Post date:** [April 6, 2020, 12:20am UTC](https://community.thunkable.com/t/tunning-loop-performance/556725/7 "2020-04-06T00:20:48Z")

</div>

Great, Thanks Jared so much.  
well, i will find the way to convert some my loop to function type variables to speed it up.  
this is my real first app  
[https://x.thunkable.com/projects/5e84665aeb614](https://x.thunkable.com/projects/5e84665aeb614)

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 11:39am UTC](https://community.thunkable.com/t/tunning-loop-performance/556725/8 "2024-11-08T11:39:22Z")

</div>


