# 27 seconds to build a simple C code?

**URL:** <https://travis-ci.community/t/27-seconds-to-build-a-simple-c-code/11560>\
**Category:** C++\
**Tags:** travis-build\
**Created:** [May 5, 2021, 6:37am UTC](https://travis-ci.community/t/27-seconds-to-build-a-simple-c-code/11560 "2021-05-05T06:37:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SolarUltima](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/solarultima/32/4019_2.png) [@SolarUltima](https://travis-ci.community/u/SolarUltima)\
**Post date:** [May 5, 2021, 6:37am UTC](https://travis-ci.community/t/27-seconds-to-build-a-simple-c-code/11560/1 "2021-05-05T06:37:22Z")

</div>

`.travis.yml`

```auto
language: C

script: make

```

Makefile

```auto
all:
    gcc hello.c

```

hello.c

```auto
int main(){

  return 0;
}

```

any ideas on what the slow down is?

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [May 5, 2021, 6:39am UTC](https://travis-ci.community/t/27-seconds-to-build-a-simple-c-code/11560/2 "2021-05-05T06:39:13Z")

</div>

Hey @SolarUltima,

Travis not only has to build your C code, it also has to create the environment provisionally – in which it has access to a C complier to build your code, and spin up the rest of the dependencies.

Creating an environment (especially for the first time, will take a bit of time).

Happy building!  
Montana Mendy

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [May 5, 2021, 7:29am UTC](https://travis-ci.community/t/27-seconds-to-build-a-simple-c-code/11560/3 "2021-05-05T07:29:11Z")

</div>

To add on to this a little bit via I felt the explanation I gave was a bit vague, you can on some occasion speed the builds up for example, you have something like this in your `.travis.yml` :

```auto
---
  os: linux
  dist: xenial
  sudo: required
  language: python
  python: "3.6"
  services:
    - docker
  cache:
    directories:
      - $HOME/.conan/data
osx: &osx
  os: osx
  language: generic
  cache:
    directories:
      - $HOME/.conan/data
      - $HOME/.pyenv/versions/2.7.10/
      - /usr/local/Homebrew

```

**macOS** is part of our `.travis/install.sh`, that will look like this:

```auto
if [["`uname -s`" == 'Darwin']]; then
    curdir=`pwd`
    cd /usr/local/Homebrew/
    if [[-d Library/Taps/homebrew/homebrew-cask]]; then
        rm -rf Library/Taps/caskroom/homebrew-cask
    fi
    for d in `find $(pwd) -type d -name .git`; do
        cd `dirname $d`
        git clean -fxd
    done
    brew cleanup
    cd $curdir # Where Montana almost messed up

    brew update
    brew outdated pyenv || brew upgrade pyenv
    brew install pyenv-virtualenv
    brew install cmake || true

    if which pyenv > /dev/null; then
        eval "$(pyenv init -)"
    fi

    pyenv install 2.7.10 --skip-existing
    pyenv virtualenv 2.7.10 conan --force
    pyenv rehash
    pyenv activate conan
fi

```

And finally, in our build-script we create `packager` with additional arguments to pass to Docker, and Docker can call packager when need be:

```auto
packager = ConanMultiPackager(
  docker_build_options='--mount type=bind,source=$HOME/.conan/data,destination=/home/conan/.conan/data',
)
packager.add_common_builds()

```

This is one example on how you can _improve_ build times with bash scripts, and certain methods. Sometimes it’s unavoidable.

Happy building!  
Montana Mendy

---

<div class="post-metadata">

**Author:** ![SolarUltima](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/solarultima/32/4019_2.png) [@SolarUltima](https://travis-ci.community/u/SolarUltima)\
**Post date:** [May 5, 2021, 9:30am UTC](https://travis-ci.community/t/27-seconds-to-build-a-simple-c-code/11560/4 "2021-05-05T09:30:38Z")

</div>

whoa @Montana!! what you wrote out actually worked for me the first build, I cannot keep thanking you enough for all the help recently, you seriously are a yaml master!!!

---

<div class="post-metadata">

**Author:** ![Montana](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/montana/32/9566_2.png) [@Montana](https://travis-ci.community/u/Montana)\
**Post date:** [May 5, 2021, 9:38am UTC](https://travis-ci.community/t/27-seconds-to-build-a-simple-c-code/11560/5 "2021-05-05T09:38:53Z")

</div>

Hey @SolarUltima,

I wouldn’t consider myself a YAML master, I just have a really good understanding of it. I think it would be hard for anyone to call themselves a “YAML Master”. I’m good at it, but definitely no master, I appreciate your kind words though.

Happy building!  
Montana Mendy
