[Csnd] tables vs arrays

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] tables vs arrays

Dave Seidel
Hi all,

I am curious about the performance implications of arrays vs tables. For example, if I use GEN51 to build a table of tuning frequencies, one for each MIDI not number, is it any more efficient to copy the resulting table to an array and use it like so

    ifreq = gi_freq_array[notnum()]

vs using the table directly like so

   ifreq = tablei(notnmum(), gi_freq_table)

Thanks,
Dave

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] tables vs arrays

Victor Lazzarini-2
We need to measure. The array expression gets expanded to a call to array_get. So the question is whether this opcode is faster than “table”

Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy
Maynooth University
Ireland

On 19 Apr 2018, at 14:02, Dave Seidel <[hidden email]> wrote:

Hi all,

I am curious about the performance implications of arrays vs tables. For example, if I use GEN51 to build a table of tuning frequencies, one for each MIDI not number, is it any more efficient to copy the resulting table to an array and use it like so

    ifreq = gi_freq_array[notnum()]

vs using the table directly like so

   ifreq = tablei(notnmum(), gi_freq_table)

Thanks,
Dave

Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] tables vs arrays

jpff
In reply to this post by Dave Seidel
Not much in it i sspect.   A slight overhead in thetable case at init
time.

On Thu, 19 Apr 2018, Dave Seidel wrote:

> Hi all,
>
> I am curious about the performance implications of arrays vs tables. For
> example, if I use GEN51 to build a table of tuning frequencies, one for each
> MIDI not number, is it any more efficient to copy the resulting table to an
> array and use it like so
>
>     ifreq = gi_freq_array[notnum()]
>
> vs using the table directly like so
>
>    ifreq = tablei(notnmum(), gi_freq_table)
>
> Thanks,
> Dave
>
> Csound mailing list [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
> https://github.com/csound/csound/issues Discussions of bugs and features can
> be posted here
>
Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] tables vs arrays

jpff
and of cource tablei interpolates and array access d0es not.  So talei
does two lookups while array only does 1 as the arg is rounded


On Thu, 19 Apr 2018, jpff wrote:

> Not much in it i sspect.   A slight overhead in thetable case at init time.
>
> On Thu, 19 Apr 2018, Dave Seidel wrote:
>
>> Hi all,
>>
>> I am curious about the performance implications of arrays vs tables. For
>> example, if I use GEN51 to build a table of tuning frequencies, one for
>> each
>> MIDI not number, is it any more efficient to copy the resulting table to an
>> array and use it like so
>>
>>     ifreq = gi_freq_array[notnum()]
>>
>> vs using the table directly like so
>>
>>    ifreq = tablei(notnmum(), gi_freq_table)
>>
>> Thanks,
>> Dave
>>
>> Csound mailing list [hidden email]
>> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
>> https://github.com/csound/csound/issues Discussions of bugs and features
>> can
>> be posted here
>>
>
> Csound mailing list
> [hidden email]
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
>       https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] tables vs arrays

Dave Seidel
In this case no interpolation is need. But you're probably right, the perf difference is probably not significant. Will likely use the array version in any case as I prefer the syntax.

On Thu, Apr 19, 2018 at 10:07 AM, jpff <[hidden email]> wrote:
and of cource tablei interpolates and array access d0es not.  So talei does two lookups while array only does 1 as the arg is rounded



On Thu, 19 Apr 2018, jpff wrote:

Not much in it i sspect.   A slight overhead in thetable case at init time.

On Thu, 19 Apr 2018, Dave Seidel wrote:

Hi all,

I am curious about the performance implications of arrays vs tables. For
example, if I use GEN51 to build a table of tuning frequencies, one for each
MIDI not number, is it any more efficient to copy the resulting table to an
array and use it like so

    ifreq = gi_freq_array[notnum()]

vs using the table directly like so

   ifreq = tablei(notnmum(), gi_freq_table)

Thanks,
Dave

Csound mailing list [hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to
https://github.com/csound/csound/issues Discussions of bugs and features can
be posted here


Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
      https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Csound mailing list
[hidden email]
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
       https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here



--
Csound mailing list [hidden email] https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here