Csound Csound-dev Csound-tekno Search About

[Csnd] tables vs arrays

Date2018-04-19 14:02
FromDave Seidel
Subject[Csnd] tables vs arrays
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 Csound@listserv.heanet.ie 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

Date2018-04-19 14:19
FromVictor Lazzarini
SubjectRe: [Csnd] tables vs arrays
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 <dave.seidel@GMAIL.COM> 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 Csound@listserv.heanet.ie 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

Date2018-04-19 14:44
Fromjpff
SubjectRe: [Csnd] tables vs arrays
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 Csound@listserv.heanet.ie
> 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
Csound@listserv.heanet.ie
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

Date2018-04-19 15:07
Fromjpff
SubjectRe: [Csnd] tables vs arrays
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 Csound@listserv.heanet.ie
>> 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
> Csound@listserv.heanet.ie
> 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
Csound@listserv.heanet.ie
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

Date2018-04-19 16:53
FromDave Seidel
SubjectRe: [Csnd] tables vs arrays
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 <jpff@codemist.co.uk> 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 Csound@listserv.heanet.ie
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
Csound@listserv.heanet.ie
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
Csound@listserv.heanet.ie
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 Csound@listserv.heanet.ie 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