DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
  1. DZone
  2. Software Design and Architecture
  3. Integration
  4. NuGet Perf–Setup and Testing

NuGet Perf–Setup and Testing

Oren Eini user avatar by
Oren Eini
·
Sep. 19, 12 · Interview
Like (0)
Save
Tweet
Share
2.72K Views

Join the DZone community and get the full member experience.

Join For Free

i built a web api application to serve as the test bed. it has a ravencontroller, which looks like this:

public class ravencontroller : apicontroller
{
    private static idocumentstore documentstore;

    public static idocumentstore documentstore
    {
        get
        {
            if (documentstore == null)
            {
                lock (typeof (ravencontroller))
                {
                    if (documentstore != null)
                        return documentstore;
                    documentstore = new documentstore
                        {
                            url = "http://localhost:8080",
                            defaultdatabase = "nuget"
                        }.initialize();
                    indexcreation.createindexes(typeof (packages_search).assembly, documentstore);
                }
            }
            return documentstore;
        }
    }

    public idocumentsession documentsession { get; set; }

    public override async task<httpresponsemessage> executeasync(httpcontrollercontext controllercontext, cancellationtoken cancellationtoken)
    {
        using (documentsession = documentstore.opensession())
        {
            httpresponsemessage result = await base.executeasync(controllercontext, cancellationtoken);
            documentsession.savechanges();
            return result;
        }
    }
}

and now we have the following controllers:

public class packagescontroller : ravencontroller
{
    public ienumerable<packages_search.reduceresult> get(int page = 0)
    {
        return documentsession.query<packages_search.reduceresult, packages_search>()
            .where(x=>x.isprerelease == false)
            .orderbydescending(x=>x.downloadcount)
                .thenby(x=>x.created)
            .skip(page*30)
            .take(30)
            .tolist();
    }
}

public class searchcontroller : ravencontroller
{
    public ienumerable<packages_search.reduceresult> get(string q, int page = 0)
    {
        return documentsession.query<packages_search.reduceresult, packages_search>()
            .search(x => x.query, q)
            .where(x => x.isprerelease == false)
            .orderbydescending(x => x.downloadcount)
                .thenby(x => x.created)
            .skip(page * 30)
            .take(30)
            .tolist();
    }
}

and, just for the sake of completeness, the packages_search index looks like this:

public class packages_search : abstractindexcreationtask<package, packages_search.reduceresult>
{
    public class reduceresult
    {
        public datetime created { get; set; }
        public int downloadcount { get; set; }
        public string packageid { get; set; }
        public bool isprerelease { get; set; }
        public object[] query { get; set; }
    }

    public packages_search()
    {
        map = packages => from p in packages
                          select new
                              {
                                  p.created, 
                                  downloadcount = p.versiondownloadcount, 
                                  p.packageid, 
                                  p.isprerelease,
                                  query = new object[] { p.tags, p.title, p.packageid}
                              };
        reduce = results =>
                 from result in results
                 group result by new {result.packageid, result.isprerelease}
                 into g
                 select new
                         {
                             g.key.packageid,
                             g.key.isprerelease,
                             downloadcount = g.sum(x => x.downloadcount),
                             created = g.select(x => x.created).orderby(x => x).first(),
                             query = g.selectmany(x=>x.query).distinct()
                         };

        store(x=>x.query, fieldstorage.no);
    }
}

all right, that's enough setup -- now let's talk about the actual structure of the load tests. for these, we used vs 2012 load testing tool. we defined the following tests...

just browsing through the packages listing:

image

browsing a bit then searching, and then narrowing the search:

image

and finally, searching a few packages by their id, tags, etc:

image

i then defined the following load test:

image

with the following distribution:

image

finally, we have the way we actually run the test:

image

we get 20 seconds of warm up, then 5 minutes of tough load.

NuGet Testing Web API Load testing application Distribution (differential geometry) Listing (computer)

Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Agile Scrum and the New Way of Work in 2023
  • How To Get Page Source in Selenium Using Python
  • How To Use Terraform to Provision an AWS EC2 Instance
  • Continuous Development: Building the Thing Right, to Build the Right Thing

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: